Beispiel #1
0
        public AssetForm(AssetElement ae, Form parentWindow, TreeNode node)
        {
            // Creates a new asset form for a given asset element
            Node      = node;
            Asset     = ae;
            MdiParent = parentWindow;
            Initialize();

            // Create subsystem icons for asset subsystems
            int currX = 32;
            int currY = 32;

            foreach (SubsystemElement sub in ae.Subsystems)
            {
                // Create new icon
                SubsystemIcon newIcon = new SubsystemIcon();
                newIcon.MouseDown += new MouseEventHandler(drawingCanvas1.SubsystemClicked);
                newIcon.MouseMove += new MouseEventHandler(drawingCanvas1.newIcon_MouseMove);
                newIcon.subsystem  = sub;
                newIcon.Location   = new Point(currX, currY);
                newIcon.Parent     = drawingCanvas1;
                newIcon.BringToFront();
                int    seed   = (int)(DateTime.UtcNow.TimeOfDay.Ticks);
                Random random = new Random(seed);
                Thread.Sleep((int)(random.NextDouble() * 100));
                newIcon.Shade = MagicColors.RandomColor(40);
                drawingCanvas1.SubsystemIcons.Add(newIcon);

                // Update location of icons
                currX += 64;
                currY  = currY == 32 ? 128 : 32;
            }
        }
Beispiel #2
0
        public void OnControlMove(object sender, MouseEventArgs e)
        {
            // A subsystem control has been moved; register event
            SubsystemIcon icon   = (SubsystemIcon)sender;
            SubsystemIcon before = new SubsystemIcon();

            before.Location = new Point(icon.PreviousLocation.X, icon.PreviousLocation.Y);
            SubsystemIcon after = new SubsystemIcon();

            after.Location = new Point(icon.Location.X, icon.Location.Y);
            _mManager.RegisterEvent(before, after, icon, "Move Subsystem");
        }
 public void OnDoubleClick(object sender, MouseEventArgs e)
 {
     // Check sender type, respond to double-click
     if (sender.GetType() == typeof(SubsystemIcon))
     {
         // Show subsystem editor form
         SubsystemIcon icon       = (SubsystemIcon)sender;
         TreeNode      blankNode  = new TreeNode();
         SubsystemForm newSubForm = new SubsystemForm(icon.subsystem, this, blankNode);
         newSubForm.Show();
     }
     if (sender.GetType() == typeof(TargetIcon))
     {
         // Open target form that corresponds to this icon
         TargetElement target = (TargetElement)(((TargetIcon)sender).Tag);
         TreeNode      node   = getNodeFromElement(target);
         ((Form)node.Tag).Show();
     }
 }