public void OnLevelChanged()
        {
            LayerList.BeginUpdate();
            LayerList.Clear();
            string active_layer = Program.engine.MainLevel.GetActiveLayer();

            for (int i = 0; i < Program.engine.MainLevel.GetLayerCount(); ++i)
            {
                string            text = Program.engine.MainLevel.GetLayerName(i);
                EXListViewItem    item = new EXImageListViewItem(NexusEditor.Properties.Resources.layer);
                EXListViewSubItem name = new EXListViewSubItem(text);
                name.OnItemValueChanged = this.OnLayerNameChanged; name.UserData = item;
                item.AddSubItem(name);
                EXBoolListViewSubItem active = new EXBoolListViewSubItem(active_layer == text);
                active.OnItemValueChanged = this.OnActiveLayer; active.UserData = item;
                item.AddSubItem(active);
                EXBoolListViewSubItem show = new EXBoolListViewSubItem(Program.engine.MainLevel.IsLayerVisible(text));
                show.OnItemValueChanged = this.OnShowLayer; show.UserData = item;
                item.AddSubItem(show);
                EXBoolListViewSubItem islock = new EXBoolListViewSubItem(Program.engine.MainLevel.IsLayerLocked(text));
                islock.OnItemValueChanged = this.OnLockLayer; islock.UserData = item;
                item.AddSubItem(islock);
                LayerList.AddItem(item);
            }
            LayerList.EndUpdate();
            //在右侧的列表中显示当前激活层中的所有actor
            UpdateActorList(Program.engine.MainLevel.GetActiveLayer());
            OperationTooltip.Text = "就绪";
        }
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            //添加新层
            //确定可用的默认层名称
            string text;

            for (int i = 1;; ++i)
            {
                text = "新作业层" + i.ToString();
                if (!Program.engine.MainLevel.IsLayerExist(text))
                {
                    break;
                }
            }

            EXListViewItem    item = new EXImageListViewItem(NexusEditor.Properties.Resources.layer);
            EXListViewSubItem name = new EXListViewSubItem(text);

            name.OnItemValueChanged = this.OnLayerNameChanged; name.UserData = item;
            item.AddSubItem(name);
            EXBoolListViewSubItem active = new EXBoolListViewSubItem(false);

            active.OnItemValueChanged = this.OnActiveLayer; active.UserData = item;
            item.AddSubItem(active);
            EXBoolListViewSubItem show = new EXBoolListViewSubItem(true);

            show.OnItemValueChanged = this.OnShowLayer; show.UserData = item;
            item.AddSubItem(show);
            EXBoolListViewSubItem islock = new EXBoolListViewSubItem(true);

            islock.OnItemValueChanged = this.OnLockLayer; islock.UserData = item;
            item.AddSubItem(islock);
            LayerList.AddItem(item);
            // 在编辑器中对应的增加一层
            Program.engine.MainLevel.CreateNewLayer(text);
            OperationTooltip.Text = "就绪";
        }
示例#3
0
        /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         * / %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         * /                          FUNCTIONS
         * / %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         * / %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/

        /// <summary>
        // initializes the main form and objects in the heap
        /// </summary>
        public FormMain()
        {
            InitializeComponent();
            this.KeyPreview        = true;
            this.AllowTransparency = true;
            this.Padding           = new Padding(0);
            this.AutoSize          = false;
            display_canvas.Size    = new Size(1000, 1000);

            m_program.init(display_canvas.Size);

            button_round_brush.BackColor = Color.Black;

            Bitmap displayImage = m_program.getCanvasImageCopy();

            display_canvas.Size  = displayImage.Size;
            display_canvas.Image = displayImage;

            Color selectedBrushColor    = m_program.getSelectedColor();
            Color selectedBrushColorAlt = m_program.getSelectedColorAlt();

            text_input_color_alpha.Text = Convert.ToString(selectedBrushColor.A);
            text_input_color_red.Text   = Convert.ToString(selectedBrushColor.R);
            text_input_color_green.Text = Convert.ToString(selectedBrushColor.G);
            text_input_color_blue.Text  = Convert.ToString(selectedBrushColor.B);

            color_box.BackColor     = selectedBrushColor;
            color_box_alt.BackColor = selectedBrushColorAlt;
            color_black.BackColor   = Color.Black;
            color_gray.BackColor    = Color.Gray;
            color_white.BackColor   = Color.White;
            color_1.BackColor       = Color.FromArgb(255, 255, 0, 0);
            color_2.BackColor       = Color.FromArgb(255, 255, 127, 0);
            color_3.BackColor       = Color.FromArgb(255, 255, 255, 0);
            color_4.BackColor       = Color.FromArgb(255, 127, 255, 0);

            color_5.BackColor = Color.FromArgb(255, 0, 255, 0);
            color_6.BackColor = Color.FromArgb(255, 0, 255, 127);
            color_7.BackColor = Color.FromArgb(255, 0, 255, 255);
            color_8.BackColor = Color.FromArgb(255, 0, 127, 255);

            color_9.BackColor  = Color.FromArgb(255, 0, 0, 255);
            color_10.BackColor = Color.FromArgb(255, 127, 0, 255);
            color_11.BackColor = Color.FromArgb(255, 255, 0, 255);
            color_12.BackColor = Color.FromArgb(255, 255, 0, 127);

            runUnitTests();
            display_canvas.Refresh();

            //
            // layer list
            for (int i = 0; i < m_program.getLayerCount(); i++)
            {
                string s = m_program.getLayerText(i);
                layerList.AddItem(s);
            }
            layerList.LayerItemsChanged += (s, e) =>
            {
                int selected = layerList.m_selectedItem;

                if (selected < 0)
                {
                    return;
                }

                m_program.changeActiveLayer(selected);

                display_canvas.Image = m_program.getCanvasImageCopy();
                display_canvas.Refresh();
            };
            layerList.LayerItemQuickAdd += (s, e) =>
            {
                Rectangle rec = m_program.getCurrentLayerRegion();
                m_program.addLayer(null, rec.Size, rec.Location);
                LayerList list = s as LayerList;
                list.AddItem(null);
            };
            layerList.LayerItemAdd += (s, e) =>
            {
                DialogNewLayer dialog = new DialogNewLayer();
                DialogResult   result = dialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    // add layer to program
                    m_program.addLayer(
                        dialog.m_name,
                        new Size(dialog.m_width, dialog.m_height),
                        new Point(0, 0));

                    // add layer to layer list control
                    layerList.AddItem(dialog.m_name);

                    // update display
                    updateCanvasImage();
                }
            };
            layerList.LayerItemRemove += (s, e) =>
            {
                Console.Write("\n2");
            };
            layerList.LayerItemButtonVisibilityClick += (s, e) =>
            {
                ListItem item = s as ListItem;
                m_program.toggleLayerVisiblity(item.m_id);
                updateCanvasImage();
            };
            // END layer list
            //
        }
示例#4
0
    public DialogTestSkin()
    {
        this.Size = new Size(400, 310);

        label = new SkinnedLabel();

        menuStrip              = new SkinnedMenuStrip();
        menuStripItem1         = new SkinnedToolStripItem();
        menuStripItem2         = new SkinnedToolStripItem();
        menuStripItemItem1     = new SkinnedToolStripItem();
        menuStripItemItem2     = new SkinnedToolStripItem();
        menuStripItemItem3     = new SkinnedToolStripItem();
        menuStripItemItemItem1 = new SkinnedToolStripItem();
        menuStripItemItemItem2 = new SkinnedToolStripItem();
        menuStripItemItemItem3 = new SkinnedToolStripItem();

        panel               = new SkinnedPanel();
        textBox             = new SkinnedTextBox();
        textBoxMarked       = new TextBoxMarked("Type Text...");
        textBoxNumberMarked = new TextBoxMarked("Type Number...");
        button              = new SkinnedButton();
        button2             = new SkinnedButton();

        layerList = new LayerList(150, 200);

        // set values
        label.Location     = new Point(20, 30);
        menuStrip.Location = new Point(0, 0);

        panel.Location               = new Point(200, 30);
        textBox.Location             = new Point(50, 10);
        textBoxMarked.Location       = new Point(50, 35);
        textBoxNumberMarked.Location = new Point(50, 60);
        button.Location              = new Point(50, 100);
        button2.Location             = new Point(50, 140);

        layerList.Location = new Point(20, 60);

        layerList.LayerItemQuickAdd += (s, e) =>
        {
            LayerList list = s as LayerList;
            list.AddItem(null);
        };
        layerList.LayerItemAdd += (s, e) =>
        {
            string str = textBox.Text;
            layerList.AddItem(str);
        };
        layerList.LayerItemRemove += (s, e) =>
        {
            int i = layerList.m_selectedItem;
            if (i >= 0)
            {
                layerList.removeItem(i, e);
            }
            else
            {
                Console.Write("\nClick this to delete the selected layer.");
            }
        };

        button.MouseUp += (s, e) =>
        {
            Console.Write("\nThis button does nothing.");
        };

        button2.MouseUp += (s, e) =>
        {
            Console.Write("\npoke.");
        };

        layerList.LayerItemsChanged += (s, e) =>
        {
            int selected = layerList.m_selectedItem;

            if (selected < 0)
            {
                return;
            }

            label.Text = selected.ToString();
        };



        // add controls
        menuStripItemItem1.DropDownItems.Add(menuStripItemItemItem1);
        menuStripItemItem1.DropDownItems.Add(menuStripItemItemItem2);
        menuStripItemItem1.DropDownItems.Add(menuStripItemItemItem3);
        menuStripItem1.DropDownItems.Add(menuStripItemItem1);
        menuStripItem1.DropDownItems.Add(menuStripItemItem2);
        menuStripItem1.DropDownItems.Add(menuStripItemItem3);
        menuStrip.Items.Add(menuStripItem1);
        menuStrip.Items.Add(menuStripItem2);

        panel.Controls.Add(textBox);
        panel.Controls.Add(textBoxMarked);
        panel.Controls.Add(textBoxNumberMarked);
        panel.Controls.Add(button);
        panel.Controls.Add(button2);

        this.Controls.Add(label);
        this.Controls.Add(panel);
        this.Controls.Add(layerList);
        this.Controls.Add(menuStrip);
    }