Beispiel #1
0
        private void editLayoutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (LayoutForm layoutWindow = new LayoutForm(LayoutSelectorComboBox.Items, LayoutSelectorComboBox.SelectedItem.ToString()))
            {
                DialogResult result = layoutWindow.ShowDialog();
                if (result == DialogResult.OK)
                {
                    if (File.Exists(ButtonLayoutsPath + layoutWindow.name + ".json"))
                    {
                        File.Delete(ButtonLayoutsPath + layoutWindow.name + ".json");
                    }
                    File.Move(ButtonLayoutsPath + LayoutSelectorComboBox.SelectedItem.ToString() + ".json", ButtonLayoutsPath + layoutWindow.name + ".json");

                    /*
                     * When we save the layout it saves to the default name layout(current layout), so we got change the default layout to the new name before saving.
                     * Otherwise we would endup with both the old layout name and the new one.
                     */
                    //Changes save location to the new one, by changin the default/current layout var.
                    CurrentLayout = layoutWindow.name;
                    //Saves layout to new file.
                    SaveLayout();
                    //Reloads layout list, changes to the new name one, unloads buttons, reloads buttons.
                    UpdateLayouts();
                }
            }
        }
Beispiel #2
0
 private void addLayoutToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (LayoutForm layoutWindow = new LayoutForm(LayoutSelectorComboBox.Items))
     {
         DialogResult result = layoutWindow.ShowDialog();
         if (result == DialogResult.OK)
         {
             File.WriteAllText(ButtonLayoutsPath + layoutWindow.name + ".json", "[]");
             //We save the current layout and set the default layout the new one so that
             //when it loads the layout list it changes the layout to the new one.
             SaveLayout();
             CurrentLayout = layoutWindow.name;
             UpdateLayouts();
         }
     }
 }