示例#1
0
        /// <summary>
        /// Run the active document's target (output) file. Source files and their dependencies
        /// will be recompiled conditionally if out of date or unconditionally.
        /// </summary>
        /// <param name="compileAll">Compile dependencies unconditionally if true.</param>
        /// <returns>True if the action completed successfully.</returns>
        public bool RunActiveDocument(bool compileAll)
        {
            if (!_mainForm.SaveAllDocuments())
            {
                _mainForm.SetStatusBarMessage(Resources.BuildHalted);
                return(false);
            }

            PinnedFile pinnedFile =
                _buildToolManager.PinnedFiles.GetPinnedFile(
                    Directory.GetCurrentDirectory());

            if (pinnedFile != null && pinnedFile.Selected)
            {
                return(Run(
                           pinnedFile.FileInfo,
                           FileTools.ReadFile(pinnedFile.Path),
                           compileAll));
            }
            else
            {
                return(Run(
                           GetActiveDocumentInfo(),
                           GetActiveDocumentContent(),
                           compileAll));
            }
        }
示例#2
0
        private void UI_TOOLBAR_PIN_Click(object sender, EventArgs e)
        {
            PinnedFile pinnedFile =
                _buildToolManager.PinnedFiles.GetPinnedFile(
                    Directory.GetCurrentDirectory());

            if (pinnedFile != null)
            {
                pinnedFile.Selected = !pinnedFile.Selected;
            }

            UpdatePinFileStatus();
        }
示例#3
0
        /// <summary>
        /// Get the type of the pinned or active document.
        /// </summary>
        /// <returns>A document type.</returns>
        public DocumentType GetPinnedOrActiveDocumentType()
        {
            PinnedFile pinnedFile =
                _buildToolManager.PinnedFiles.GetPinnedFile(
                    Directory.GetCurrentDirectory());

            if (pinnedFile != null && pinnedFile.Selected)
            {
                return(pinnedFile.DocumentType);
            }
            else
            {
                return(GetActiveDocumentType());
            }
        }
 /// <summary>
 /// Remove a file from the collection.
 /// </summary>
 /// <param name="pinnedFile">A PinnedFile instance.</param>
 public void Remove(PinnedFile pinnedFile)
 {
     Remove(pinnedFile.Directory);
 }
        /// <summary>
        /// Add a file to the collection by path.
        /// </summary>
        /// <param name="path">The file path.</param>
        public void Add(string path)
        {
            PinnedFile pinnedFile = new PinnedFile(path);

            Add(pinnedFile);
        }
 /// <summary>
 /// Add a file to the collection.
 /// </summary>
 /// <param name="pinnedFile">A PinnedFile instance.</param>
 public void Add(PinnedFile pinnedFile)
 {
     _pinnedFiles[pinnedFile.Directory] = pinnedFile;
 }
示例#7
0
        private void UpdatePinFileStatus()
        {
            string currentDirectory =
                Directory.GetCurrentDirectory();

            PinnedFile pinnedFile =
                _buildToolManager.PinnedFiles.
                GetPinnedFile(currentDirectory);

            /*
             * Is it still valid?
             */

            if (pinnedFile != null && !pinnedFile.Exists())
            {
                _buildToolManager.PinnedFiles.Remove(pinnedFile);
                pinnedFile = null;
            }

            /*
             * PinnedFile is now null or a valid file path.
             * Reset the UI to base state.
             */

            _toolbarPin.Enabled       = false;
            _toolbarPin.Checked       = false;
            _toolbarPinSelect.Enabled = false;
            _toolbarPinSelect.DropDownItems.Clear();

            /*
             * Now refresh the file list.
             */

            List <String> documentTypes =
                _buildToolManager.BuildTools.GetDocumentTypes();

            string[] files = Directory.GetFiles(currentDirectory);

            ThemeFlags flags = _applicationManager.
                               ClientProfile.ThemeFlags;

            bool applyTheme = flags != null &&
                              flags.MenuForeColor != Color.Empty;

            foreach (string file in files)
            {
                FileInfo fi = new FileInfo(file);

                if (!documentTypes.Contains(fi.Extension))
                {
                    continue;
                }

                ToolStripMenuItem item = new ToolStripMenuItem();
                item.Text = Path.GetFileName(file);
                item.Tag  = file;

                // Apply theme color if available.
                if (applyTheme)
                {
                    item.ForeColor = flags.MenuForeColor;
                }

                if (pinnedFile != null)
                {
                    item.Checked = pinnedFile.Matches(file);
                }

                _toolbarPinSelect.DropDownItems.Add(item);
            }

            /*
             * Update the UI based on what we found.
             */

            if (_toolbarPinSelect.DropDownItems.Count > 0)
            {
                _toolbarPinSelect.Enabled = true;
            }

            if (pinnedFile != null)
            {
                _toolbarPin.Enabled = true;
                _toolbarPin.Checked = pinnedFile.Selected;

                _toolbarPin.ToolTipText = String.Format("{0}: {1}",
                                                        Resources.ToolbarPinFile,
                                                        pinnedFile.Name);
            }
            else
            {
                _toolbarPin.ToolTipText = Resources.ToolbarPinFile;
            }

            UpdateBuildToolStatus();
        }