Example #1
0
 public void StoreOrderPosition(
     object threadPoolManager,
     object postExecuteCallback,
     AsynchronousMode asynchronousMode,
     object userState)
 {
     _project.MarkAsModified();
 }
        /// <summary>
        /// Ensures the items order positions set.
        /// </summary>
        public void EnsureItemsOrderPositionsSet(
            object threadPoolManager,
            TreeListNode parentNode,
            AsynchronousMode asynchronousMode)
        {
            var previousOrderPosition = -1;

            var nodes = parentNode == null ? Nodes : parentNode.Nodes;

            // Take the current item order of the items in the
            // list and ensure the order position is
            // ascending (not naturally immediate following numbers).
            var itemIndex = 0;

            while (itemIndex < nodes.Count)
            {
                var listViewItem = nodes[itemIndex];

                var obj = (IOrderPosition)listViewItem.Tag;

                var currentOrderPosition = obj.OrderPosition;

                // Must adjust.
                if (currentOrderPosition <= previousOrderPosition)
                {
                    // Increment.
                    var newCurrentOrderPosition = previousOrderPosition + 1;

                    if (obj.OrderPosition != newCurrentOrderPosition)
                    {
                        // New order position.
                        obj.OrderPosition = newCurrentOrderPosition;

                        // Mark as modified, but do no display update,
                        // since nothing VISUAL has changed.
                        obj.StoreOrderPosition(threadPoolManager, null, asynchronousMode, null);
                    }

                    // Remember for next turn.
                    previousOrderPosition = newCurrentOrderPosition;
                }
                else
                {
                    // Remember for next turn.
                    previousOrderPosition = currentOrderPosition;
                }

                itemIndex++;
            }
        }
		/// <summary>
		/// Ensures the items order positions set.
		/// </summary>
		public void EnsureItemsOrderPositionsSet(
			object threadPoolManager,
			TreeListNode parentNode,
			AsynchronousMode asynchronousMode)
		{
			var previousOrderPosition = -1;

			var nodes = parentNode == null ? Nodes : parentNode.Nodes;

			// Take the current item order of the items in the
			// list and ensure the order position is
			// ascending (not naturally immediate following numbers).
			var itemIndex = 0;
			while (itemIndex < nodes.Count)
			{
				var listViewItem = nodes[itemIndex];

				var obj = (IOrderPosition)listViewItem.Tag;

				var currentOrderPosition = obj.OrderPosition;

				// Must adjust.
				if (currentOrderPosition <= previousOrderPosition)
				{
					// Increment.
					var newCurrentOrderPosition = previousOrderPosition + 1;

					if (obj.OrderPosition != newCurrentOrderPosition)
					{
						// New order position.
						obj.OrderPosition = newCurrentOrderPosition;

						// Mark as modified, but do no display update,
						// since nothing VISUAL has changed.
						obj.StoreOrderPosition(threadPoolManager, null, asynchronousMode, null);
					}

					// Remember for next turn.
					previousOrderPosition = newCurrentOrderPosition;
				}
				else
				{
					// Remember for next turn.
					previousOrderPosition = currentOrderPosition;
				}

				itemIndex++;
			}
		}
		//private void updateNodeStateImage(
		//    FileGroup fileGroup,
		//    FileGroupStates state )
		//{
		//    if ( treeView.Nodes.Count > 0 )
		//    {
		//        // For now, FileGroups are always in level 1.
		//        // This changes later.
		//        foreach ( TreeListNode node in treeView.Nodes[0].Nodes )
		//        {
		//            var fg = (FileGroup)node.Tag;

		//            if ( fg.GetChecksum( _project ) == fileGroup.GetChecksum( _project ) )
		//            {
		//                updateNodeStateImage( node, state );
		//                break;
		//            }
		//        }
		//    }
		//}

		private void updateNodeStateImage(
			TreeListNode node,
			AsynchronousMode asynchronous)
		{
			if (node != null)
			{
				var si = node.Tag as ITranslationStateInformation;

				if (si != null)
				{
					if (asynchronous == AsynchronousMode.Synchronous)
					{
						var stateImageIndex = (int)si.TranslationStateColor;

						if (node.StateImageIndex != stateImageIndex)
						{
							node.StateImageIndex = stateImageIndex;

							if (si is FileGroup)
							{
								foreach (TreeListNode childNode in node.Nodes)
								{
									childNode.StateImageIndex = stateImageIndex;
								}
							}
						}
					}
					else
					{
						// Fill with default.
						if (node.StateImageIndex != (int)FileGroupStateColor.Grey)
						{
							node.StateImageIndex = (int)FileGroupStateColor.Grey;

							if (si is FileGroup)
							{
								foreach (TreeListNode childNode in node.Nodes)
								{
									childNode.StateImageIndex = (int)FileGroupStateColor.Grey;
								}
							}
						}

						// --

						// Actually calculate, populate when finished calculating.
						var info = new AsyncInfo { Node = node, StateInfo = si };
						enqueue(info);
					}
				}

				// --

				// Update parents.
				updateNodeStateImage(node.ParentNode, asynchronous);
			}
		}