Пример #1
0
 private void Button_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         if (Secretary.GetActiveProfile().profile_name == "Default")
         {
             removeToolStripMenuItem.Visible = false;
         }
         else
         {
             removeToolStripMenuItem.Visible = true;
         }
         ButtonRightClickMenu.Show(Button, e.Location);
     }
     else if (Control.ModifierKeys == Keys.Shift)
     {
     }
     else if (Control.ModifierKeys == Keys.Control)
     {
     }
     else
     {
         owner.DisplayRuleRoll(Button.Text);
     }
 }
Пример #2
0
 public void DisplayRuleRoll(string rule_name)
 {
     StructCollection.Rule rule = Secretary.GetRule(rule_name);
     OpenDisplay();
     results_display.AddRollDisplay(new RollDisplay(DiceTower.RollDice(rule.dice), DiceTower.SumModifiers(rule.modifiers), rule));
     this.Focus();
 }
Пример #3
0
        private void Main_FormClosing(object sender, FormClosingEventArgs e)
        {
            ReorderRules();
            Secretary.WriteRulesToFile();

            Properties.Settings.Default.MainFormState = this.WindowState;
            if (this.WindowState == FormWindowState.Normal)
            {
                Properties.Settings.Default.MainFormLocation = this.Location;
                Properties.Settings.Default.MainFormSize     = this.Size;
            }
            else
            {
                Properties.Settings.Default.MainFormLocation = this.RestoreBounds.Location;
                Properties.Settings.Default.MainFormSize     = this.RestoreBounds.Size;
            }
            Properties.Settings.Default.LoadMainFormSettings = true;
            Properties.Settings.Default.Save();
            if (e.CloseReason == CloseReason.UserClosing)
            {
                try
                {
                    results_display.Close();
                }
                catch (Exception) { }
            }
        }
Пример #4
0
 private void ActivateProfile(string profile_name)
 {
     Secretary.SetActiveProfile(profile_name);
     RefreshRuleButtons();
     foreach (ToolStripItem profile in ProfilesMenuItem.DropDownItems)
     {
         if (profile.GetType() != typeof(ToolStripMenuItem))
         {
             continue;
         }
         if (profile.Text == profile_name)
         {
             ((ToolStripMenuItem)profile).Checked = true;
         }
         else
         {
             ((ToolStripMenuItem)profile).Checked = false;
         }
     }
     if (profile_name == "Default")
     {
         importToolStripMenuItem.Visible = false;
         ProfilesMenuItem.Text           = "Profiles";
     }
     else
     {
         importToolStripMenuItem.Visible = true;
         ProfilesMenuItem.Text           = profile_name;
     }
 }
Пример #5
0
 private void RefreshRuleButtons()
 {
     RuleLayout.Controls.Clear();
     foreach (string rule_name in Secretary.GetActiveProfile().rule_names)
     {
         RuleLayout.Controls.Add(new RuleButton(this, rule_name, Secretary.GetRule(rule_name).colour));
     }
 }
Пример #6
0
 private void DeleteProfile(string profile_name)
 {
     if (Secretary.GetActiveProfile().profile_name == profile_name)
     {
         ActivateProfile("Default");
     }
     Secretary.DeleteProfile(profile_name);
     ProfilesMenuItem.DropDownItems.Remove(ProfilesMenuItem.DropDownItems.Find(profile_name, false)[0]);
 }
Пример #7
0
        private void ReorderRules()
        {
            List <string> rule_name_order = new List <string>();

            foreach (RuleButton rule in RuleLayout.Controls)
            {
                rule_name_order.Add(rule.GetRuleName());
            }
            Secretary.ReorderRules(rule_name_order);
        }
Пример #8
0
 private void NameTextbox_Change(object sender, EventArgs e)
 {
     this.Text = NameTextbox.Text;
     if (Secretary.RuleExists(NameTextbox.Text))
     {
         NameTextbox.ForeColor = Color.Red;
     }
     else
     {
         NameTextbox.ForeColor = Color.Black;
     }
 }
Пример #9
0
 private void SetupProfiles()
 {
     ProfilesMenuItem.DropDown.Closing += ProfilesDropDown_Closing;
     foreach (StructCollection.Profile profile in Secretary.GetProfiles())
     {
         if (profile.profile_name != "Default")
         {
             AddProfileToDropdown(profile.profile_name);
         }
     }
     ActivateProfile(Secretary.GetActiveProfile().profile_name);
 }
Пример #10
0
 public void EditRule(string rule_name)
 {
     StructCollection.Rule rule = Secretary.GetRule(rule_name);
     if (rule.results.type == StructCollection.ResultCollection.Type.Event)
     {
         ShowEditEventRule(rule);
     }
     else if (rule.results.type == StructCollection.ResultCollection.Type.Damage)
     {
         ShowEditAttackRule(rule);
     }
 }
Пример #11
0
        private void ToolStripTextBox1_TextChanged(object sender, EventArgs e)
        {
            ToolStripTextBox sender_menuitem = (ToolStripTextBox)sender;

            if (Secretary.ProfileExists(sender_menuitem.Text))
            {
                sender_menuitem.ForeColor = Color.Red;
            }
            else
            {
                sender_menuitem.ForeColor = Color.Black;
            }
        }
Пример #12
0
        private void button1_Click(object sender, EventArgs e)
        {
            List <string> selected_rules = new List <string>();

            selected_rules.AddRange(DamageRulesListbox.SelectedItems.Cast <string>());
            selected_rules.AddRange(EventRulesListbox.SelectedItems.Cast <string>());
            if (selected_rules.Count <= 0)
            {
                MessageBox.Show(this, "No rule selected for import.");
                return;
            }
            foreach (string selected_rule in selected_rules)
            {
                Secretary.AddRuleToProfile(selected_rule, profile.profile_name);
            }
            this.Close();
        }
Пример #13
0
 private void NewProfileTextbox_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         e.SuppressKeyPress = true;
         if (Secretary.ProfileExists(NewProfileTextbox.Text))
         {
             return;
         }
         if (NewProfileTextbox.Text.Trim() != "")
         {
             CreateProfile(NewProfileTextbox.Text.Trim());
             ActivateProfile(NewProfileTextbox.Text.Trim());
         }
         NewProfileTextbox.Text = "";
     }
 }
Пример #14
0
 private bool SaveRule()
 {
     if (NameTextbox.Text == "Rule Name")
     {
         MessageBox.Show("Please give this rule a name", "Name Rule");
         return(false);
     }
     if (NameTextbox.Text != starting_rule_name && Secretary.RuleExists(NameTextbox.Text))
     {
         MessageBox.Show("A rule with the name '" + NameTextbox.Text + "' already exists.", "Rename Rule");
         return(false);
     }
     current_rule.rule_name = NameTextbox.Text;
     StoreDice(ref current_rule);
     StoreModifiers(ref current_rule);
     StoreEventResults(ref current_rule);
     Secretary.SaveRule(starting_rule_name, current_rule);
     return(true);
 }
Пример #15
0
 private bool SaveRule()
 {
     if (NameTextbox.Text == "Rule Name")
     {
         NameTextbox.ForeColor = Color.Red;
         MessageBox.Show("Please give this rule a name", "Name Rule");
         return(false);
     }
     if (NameTextbox.Text != starting_rule_name && Secretary.RuleExists(NameTextbox.Text))
     {
         MessageBox.Show("A rule with the name '" + NameTextbox.Text + "' already exists.", "Rename Rule");
         return(false);
     }
     current_rule.rule_name = NameTextbox.Text;
     ((StructCollection.Damage)current_rule.results).damage_type = DamageTypeTextbox.Text != "Damage Type" ? DamageTypeTextbox.Text : "";
     StoreDice(ref current_rule);
     StoreModifiers(ref current_rule);
     StoreFunctionalities(ref current_rule);
     Secretary.SaveRule(starting_rule_name, current_rule);
     return(true);
 }
Пример #16
0
        private void ImportRules_Load(object sender, EventArgs e)
        {
            if (Properties.Settings.Default.LoadImportFormSettings)
            {
                this.Location = Properties.Settings.Default.ImportRuleFormLocation;
                this.Size     = Properties.Settings.Default.ImportRuleFormSize;
                if (Properties.Settings.Default.ImportRuleFormState == FormWindowState.Maximized)
                {
                    this.WindowState = FormWindowState.Maximized;
                }
                else
                {
                    this.WindowState = FormWindowState.Normal;
                }
            }

            this.Text = "Import Rules to " + profile.profile_name;

            foreach (StructCollection.Rule rule in Secretary.GetRules())
            {
                if (profile.rule_names.Contains(rule.rule_name))
                {
                    continue;
                }
                if (rule.results.type == StructCollection.ResultCollection.Type.Damage)
                {
                    DamageRulesListbox.Items.Add(rule.rule_name);
                }
                else if (rule.results.type == StructCollection.ResultCollection.Type.Event)
                {
                    EventRulesListbox.Items.Add(rule.rule_name);
                }
                else
                {
                    EventRulesListbox.Items.Add(rule.rule_name);
                }
            }
        }
Пример #17
0
 public void RemoveRuleButton(RuleButton rule_button)
 {
     Secretary.RemoveRuleFromProfile(rule_button.GetRuleName());
     RuleLayout.Controls.Remove(rule_button);
 }
Пример #18
0
 private void ruleToProfileToolStripMenuItem_Click(object sender, EventArgs e)
 {
     new ImportRules(Secretary.GetActiveProfile()).ShowDialog();
     RefreshRuleButtons();
 }
Пример #19
0
 public void DeleteRuleButton(RuleButton rule_button)
 {
     Secretary.DeleteRule(Secretary.GetRule(rule_button.GetRuleName()));
     RuleLayout.Controls.Remove(rule_button);
 }
Пример #20
0
 private void CreateProfile(string profile_name)
 {
     Secretary.CreateProfile(profile_name);
     AddProfileToDropdown(profile_name);
 }