Пример #1
0
        /// <summary>
        /// Constructs the object.
        /// </summary>
        public QSetExplorer()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            _qset = null;
        }
Пример #2
0
        /// <summary>
        /// Saves a Q Set.
        /// </summary>
        /// <remarks>It is expected that the filename has been set at this point.</remarks>
        /// <param name="qSet">Q Set to save.</param>
        /// <param name="fileName">File name.</param>
        /// <returns>true if save was succeful, else false.</returns>
        private bool DoSaveQSet(QSetModel qSet)
        {
            bool result = false;

            try
            {
                using (System.IO.StreamWriter sw = new System.IO.StreamWriter(qSet.FileName, false))
                {
                    sw.Write(qSet.ToXml());
                    sw.Flush();
                    qSet.IsDirty = false;
                    result       = true;
                }
            }
            catch (Exception exc)
            {
                //TODO check if file is readonly & tidy up message box, handle IOException
                MessageBox.Show(_primaryForms.EnvironmentForm, "Unable to save file, " + exc.Message, Locale.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            SetTitleBarText();
            _menuStateManager.SetFileMenuState();

            return(result);
        }
Пример #3
0
 /// <summary>
 /// Displays a QSet in the explorer.
 /// </summary>
 /// <param name="queueSet">QSet to display.</param>
 private void DisplayQSet(QSetModel queueSet)
 {
     _qsetTreeView.Nodes.Clear();
     if (_qset != null)
     {
         QSetItemTreeNode queueSetNode = new QSetItemTreeNode(_qset);
         _qsetTreeView.Nodes.Add((QSetItemTreeNode)queueSetNode);
         DisplayQSetChildItems(queueSet, queueSetNode);
     }
 }
Пример #4
0
        /// <summary>
        /// Loads the requested Q Set.
        /// </summary>
        /// <param name="file">Full path and filename of Q Set file.</param>
        private void DoOpenQSet(string file)
        {
            try
            {
                //read the file
                string qsetFileContent = null;
                using (StreamReader sr = new StreamReader(file))
                {
                    qsetFileContent = sr.ReadToEnd();
                }

                //validate we have a valid Q Set file
                if (qsetFileContent != null)
                {
                    Validator validator = new Validator(Documents.QSetFileXsd());
                    if (validator.Validate(qsetFileContent, ValidatorShortCircuitType.OnWarning) == ValidatorResultType.Valid)
                    {
                        QSetModel qSet = QSetModel.CreateQSet(qsetFileContent);
                        qSet.FileName = file;
                        DoCloseQSet();
                        _primaryControls.SetQSetExplorerData(qSet);
                    }
                    else
                    {
                        MessageBox.Show(_primaryForms.EnvironmentForm, Locale.UserMessages.SelectedFileNotAQSetFile, Locale.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        OpenQSet();
                    }
                }
            }
            catch
            {
                MessageBox.Show(_primaryForms.EnvironmentForm, Locale.UserMessages.UnableToOpenFile, Locale.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                OpenQSet();
            }

            //refresh relevant interface components
            _primaryObjects.UserSettings.IndicateFileUsed(file);
            _primaryMenus.RefreshRecentFilesList(_primaryObjects.UserSettings.RecentFileList, _primaryObjects.UserSettings.RecentFileListMaximumEntries);
            _menuStateManager.SetFileMenuState();
        }
Пример #5
0
            /// <summary>
            /// Starts monitoring a specified Q Set.
            /// </summary>
            /// <param name="qset">Q Set to monitor.</param>
            public void Start(QSetModel qset)
            {
                //ensure any previous monitor is finished, before we re-start
                lock (this)
                {
                    //reset member variables
                    _resetEvent.WaitOne();
                    _isStopRequested   = false;
                    _itemPairHashTable = new Hashtable();
                    _monitorListView.Items.Clear();

                    if (qset != null)
                    {
                        //start the monitor
                        _resetEvent.Reset();

                        ThreadPool.QueueUserWorkItem(new WaitCallback(MonitorQSetWaitCallBack), qset);
                    }
                    else
                    {
                        _resetEvent.Set();
                    }
                }
            }
Пример #6
0
 public void SetQSetExplorerData(QSetModel qSet)
 {
     _qSetExplorerForm.QSetExplorer.QSet = qSet;
 }
Пример #7
0
 public void SetQSetExplorerActiveItemWithEdit(QSetModel qSet)
 {
     _qSetExplorerForm.QSetExplorer.QSet       = qSet;
     _qSetExplorerForm.QSetExplorer.ActiveItem = qSet;
     _qSetExplorerForm.QSetExplorer.BeginEditActiveItem();
 }
Пример #8
0
 public void SetQSetExplorerActiveItem(QSetModel qSetModel)
 {
     _qSetExplorerForm.QSetExplorer.ActiveItem = qSetModel;
 }
Пример #9
0
 public void SetQSetMonitorData(QSetModel item)
 {
     _qSetMonitorForm.QSetMonitor.QSet = item;
 }
Пример #10
0
        /// <summary>
        /// Creates a new Q Set.
        /// </summary>
        public void CreateNewQSet()
        {
            var qSet = new QSetModel("New Queue Set");

            _primaryControls.SetQSetExplorerActiveItemWithEdit(qSet);
        }