Ejemplo n.º 1
0
        private void ClassMenuItemClick(object sender, EventArgs e)
        {
            MenuItem     CurrentMenu     = (MenuItem)sender;
            string       Name            = CurrentMenu.Parent.Name;
            ResourceData CurrentResource = null;

            foreach (ResourceData R in CurrentResources)
            {
                if (R.Name.Equals(Name))
                {
                    CurrentResource = R;
                    break;
                }
            }
            TempOldResource     = CurrentResource;
            TempUpdatedResource = null;
            CurrentResources.Remove(CurrentResource);
            UpdateResourceEvent?.Invoke(CurrentResource.Name, GetIsLinkFromR(CurrentResource), CurrentMenu.Name, null, null, CurrentResource.Unit, CurrentResource.Type, CurrentResource.Comments);
        }
Ejemplo n.º 2
0
        private void NameTextBoxKeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                TextBox      CurrentTextBox  = (TextBox)sender;
                string       UpdatedName     = CurrentTextBox.Text;
                string       OldName         = CurrentTextBox.Name;
                ResourceData CurrentResource = GetResourceFromName(OldName);

                TempOldResource          = CurrentResource;
                TempUpdatedResource      = CurrentResource.Clone();
                TempUpdatedResource.Name = UpdatedName;
                CurrentResources.Remove(CurrentResource);

                UpdateResourceEvent?.Invoke(OldName, GetIsLinkFromR(CurrentResource), null, UpdatedName, null, CurrentResource.Unit, CurrentResource.Type, CurrentResource.Comments);
                e.Handled          = true;
                e.SuppressKeyPress = true;
            }
        }
Ejemplo n.º 3
0
        private void UnitMenuItemClick(object sender, EventArgs e) //refering to the right click context menu for resources.
        {
            MenuItem CurrentMenu = (MenuItem)sender;
            string   Name        = CurrentMenu.Parent.Name;

            ResourceData CurrentResource = null;

            foreach (ResourceData R in CurrentResources)
            {
                if (R.Name.Equals(Name))
                {
                    CurrentResource = R;
                    break;
                }
            }
            if (CurrentMenu.Text.Equals("New Unit..."))
            {
                //Perform add unit.
                MultipurposePopup UnitSelector = new MultipurposePopup("", "Unit:", true);
                var Result = UnitSelector.ShowDialog();
                if (Result == DialogResult.OK)
                {
                    string FullUnitName = GetUnitPlusExt(UnitSelector.MyText);
                    TempOldResource          = CurrentResource;
                    TempUpdatedResource      = CurrentResource.Clone();
                    TempUpdatedResource.Unit = FullUnitName;
                    CurrentResources.Remove(CurrentResource);
                    UpdateResourceEvent?.Invoke(CurrentResource.Name, GetIsLinkFromR(CurrentResource), null, null, null, FullUnitName, CurrentResource.Type, CurrentResource.Comments);
                    return;
                }
                else
                {
                    return;
                }
            }
            TempOldResource          = CurrentResource;
            TempUpdatedResource      = CurrentResource.Clone();
            TempUpdatedResource.Unit = CurrentMenu.Name;
            CurrentResources.Remove(CurrentResource);
            UpdateResourceEvent?.Invoke(CurrentResource.Name, GetIsLinkFromR(CurrentResource), null, null, null, CurrentMenu.Name, CurrentResource.Type, CurrentResource.Comments);
        }