Exemple #1
0
        /// <summary>
        /// Creates a new Q Set given the content of a .qset file.
        /// </summary>
        /// <param name="qSetFileContent">qset file content, as an XML string.</param>
        /// <returns>New Q Set.</returns>
        public static QSetModel CreateQSet(string qSetFileContent)
        {
            QSetModel newQSet = null;

            //start reading xml
            XPathDocument  xpathDoc = new XPathDocument(IOUtilities.StringToMemoryStream(qSetFileContent));
            XPathNavigator xpathNav = xpathDoc.CreateNavigator();

            //get root
            XPathNodeIterator ni = xpathNav.Select(QSetXmlFileFormat.RootElement.Name);

            if (ni.MoveNext())
            {
                //create qset with existing guids, or create new ones
                if (ni.Current.GetAttribute(QSetXmlFileFormat.ItemAttributes.Guid, "") != string.Empty)
                {
                    newQSet = new QSetModel
                              (
                        new Guid(ni.Current.GetAttribute(QSetXmlFileFormat.ItemAttributes.Guid, "")),
                        ni.Current.GetAttribute(QSetXmlFileFormat.ItemAttributes.Name, "")
                              );
                }
                else
                {
                    newQSet = new QSetModel(ni.Current.GetAttribute(QSetXmlFileFormat.ItemAttributes.Name, ""));
                }

                //create all of the child items
                CreateChildItems(newQSet, ni);

                newQSet.IsDirty = false;
            }

            return(newQSet);
        }
Exemple #2
0
		/// <summary>
		/// Creates a new Q Set given the content of a .qset file.
		/// </summary>
		/// <param name="qSetFileContent">qset file content, as an XML string.</param>
		/// <returns>New Q Set.</returns>
		public static QSetModel CreateQSet(string qSetFileContent)
		{
			QSetModel newQSet = null;

			//start reading xml
			XPathDocument xpathDoc = new XPathDocument(IOUtilities.StringToMemoryStream(qSetFileContent));
			XPathNavigator xpathNav = xpathDoc.CreateNavigator();
			
			//get root
			XPathNodeIterator ni = xpathNav.Select(QSetXmlFileFormat.RootElement.Name);
			if (ni.MoveNext())
			{
				//create qset with existing guids, or create new ones
				if (ni.Current.GetAttribute(QSetXmlFileFormat.ItemAttributes.Guid, "") != string.Empty)
					newQSet = new QSetModel
						(
						new Guid(ni.Current.GetAttribute(QSetXmlFileFormat.ItemAttributes.Guid, "")),
						ni.Current.GetAttribute(QSetXmlFileFormat.ItemAttributes.Name, "")
						);
				else
					newQSet = new QSetModel(ni.Current.GetAttribute(QSetXmlFileFormat.ItemAttributes.Name, ""));				
				
				//create all of the child items
				CreateChildItems(newQSet, ni);				
				
				newQSet.IsDirty = false;
			}			

			return newQSet;
		}
Exemple #3
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();
				}				
			}
Exemple #4
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);
			}			
		}
Exemple #5
0
		/// <summary>
		/// Constructs the object.
		/// </summary>
		public QSetExplorer()
		{
			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();

			_qset = null;												
		}
Exemple #6
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;
		}