Ejemplo n.º 1
0
        private void loadProject(Classes.Project project)
        {
            tabBar.CloseAllTabs();

            proj = project;
            proj.NameChanged += new Action(proj_NameChanged);
            proj.DirtyChanged += new Action<string>(proj_DirtyChanged);
            proj.ElementAdded += new Action<Classes.ICodeBlock>(proj_ElementAdded);
            proj.ElementRemoved += new Action<Classes.ICodeBlock>(proj_ElementRemoved);
            proj_NameChanged();

            RefreshEnums();
            RefreshStructs();
            RefreshTasks();
            //RefreshMethods();
            RefreshUndoMenu();

            tabBar.AddTab(new TabItem("main", Classes.CodeType.Task, proj.GetPage("main")));
            ideCanvas.Page = proj.GetPage("main");
        }
Ejemplo n.º 2
0
        private void newProjectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (proj.Dirty)
            {
                DialogResult r = MessageBox.Show(this,
                    "The Visual NXC project you are trying to close has not been saved!\r\n\r\nWould you like to save it now?",
                    "Unsaved Project...",
                    MessageBoxButtons.YesNoCancel);

                switch (r)
                {
                    case DialogResult.Cancel:
                        return;
                    case DialogResult.Yes:
                        saveProjectAsToolStripMenuItem_Click(this, null);
                        break;
                }
            }

            Classes.Project p = new Classes.Project();
            p.Initialize();
            loadProject(p);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// The main window for Visual NXC
        /// </summary>
        public MainForm()
        {
            InitializeComponent();

            #region Init Aero

            mainMenu.Renderer = menuRenderer;
            toolStrip.Renderer = menuRenderer;
            base.AeroOnOff += new Action<bool>(MainForm_AeroOnOff);
            if (IsAero())
            {
            #if !MONO //ONLY when not on MONO

                //Prepare the menustrip to be 'docked' into the titlebar...
                menuRenderer.isOnGlass = true;
                //mainMenu.Dock = DockStyle.None;
                //mainMenu.Location = new Point(22, 10);

                //Expand down to envelop the menu.
                //(if ExpandIntoFrame, then it 'sucks up' the menu into the titlebar...)
                this.ExpandAmount = mainMenu.Bottom;

                //dock everything else below it...
                //allDock.Dock = DockStyle.None;
                //allDock.Location = new Point(0, mainMenu.Bottom);
                //allDock.Size = new System.Drawing.Size(this.ClientRectangle.Width, this.ClientRectangle.Height);
                //allDock.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;

            #else //ONLY when on MONO
                //We don't want to suck it up into the titlebar...
                this.ExpandIntoFrame = false;
                this.ExpandAmount = mainMenu.Bottom;
                menuRenderer.isOnGlass = true;
            #endif
                //Enable glass extentions!
                this.ExtensionsEnabled = true;
            }

            #endregion

            #region Init UI

            //Add all of the "Items" parent nodes and specify their icons...
            TreeNode addTask = new TreeNode("Add Task", 4, 4);
            addTask.ToolTipText = "Add a task to the project...";
            addTask.Tag = "ADD_TASK";
            ThreadsTN = new TreeNode("Tasks", 0, 0, new TreeNode[] { addTask });
            itemsTreeView.Nodes.Add(ThreadsTN);
            TreeNode addMethod = new TreeNode("Add Method", 4, 4);
            addMethod.ToolTipText = "Add a method to the project...";
            addMethod.Tag = "ADD_METHOD";
            MethodsTN = new TreeNode("Methods", 1, 1, new TreeNode[] { addMethod });
            itemsTreeView.Nodes.Add(MethodsTN);
            TreeNode addEnum = new TreeNode("Add Enumeration...", 4, 4);
            addEnum.ToolTipText = "Add an enumeration to the project...";
            addEnum.Tag = "ADD_ENUM";
            EnumsTN = new TreeNode("Enumerations", 2, 2, new TreeNode[] { addEnum });
            itemsTreeView.Nodes.Add(EnumsTN);
            TreeNode addStruct = new TreeNode("Add Struct", 4, 4);
            addStruct.ToolTipText = "Add a struct to the project...";
            addStruct.Tag = "ADD_STRUCT";
            StructsTN = new TreeNode("Structs", 3, 3, new TreeNode[] { addStruct });
            itemsTreeView.Nodes.Add(StructsTN);

            itemsTreeView.ExpandAll();
            Tools.SetDoubleBuffered(itemsTreeView);
            Tools.SetDoubleBuffered(blocksTreeView);
            Tools.SetDoubleBuffered(mapDisplay);

            int result = 0;
            result += NativeMethods.SetWindowTheme(itemsTreeView.Handle, "EXPLORER", null);
            result += NativeMethods.SetWindowTheme(blocksTreeView.Handle, "EXPLORER", null);
            if (result != 0)
                Console.WriteLine("Setting TreeView theme to \"EXPLORER\" failed.");

            (toolStrip.Renderer as ToolStripProfessionalRenderer).RoundedEdges = false;

            saveFileDlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            #endregion

            #region project binds

            //Plug into these events so when know when the UI needs to update...
            Classes.Project p = new Classes.Project();
            p.Initialize();
            loadProject(p);

            tabBar.SelectedTabChanged += new Action<TabItem>(tabBar1_SelectedTabChanged);

            #endregion
        }