Ejemplo n.º 1
0
        /// <summary>
        /// Obtains a control to edit a given property. Changes to the selection set
        /// cause this method to be called again (and passed a new 'context'),
        /// unless ICacheablePropertyControl is implemented on the control. For
        /// performance reasons, it is highly recommended that the control implement
        /// the ICacheablePropertyControl interface.</summary>
        /// <param name="context">Context for property editing control</param>
        /// <returns>Control to edit the given context</returns>
        public Control GetEditingControl(PropertyEditorControlContext context)
        {
            var control = new CollectionEditingControl(context);

            SkinService.ApplyActiveSkin(control);
            return(control);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Obtains a control to edit a given property. Changes to the selection set
        /// cause this method to be called again (and passed a new 'context'),
        /// unless ICacheablePropertyControl is implemented on the control. For
        /// performance reasons, it is highly recommended that the control implement
        /// the ICacheablePropertyControl interface.</summary>
        /// <param name="context">Context for property editing control</param>
        /// <returns>Control to edit the given context</returns>
        public virtual Control GetEditingControl(PropertyEditorControlContext context)
        {
            var control = new BoundedFloatControl(context, m_min, m_max);

            SkinService.ApplyActiveSkin(control);
            return(control);
        }
Ejemplo n.º 3
0
        private void Awake()
        {
            LastTrainPos         = transform.position;
            _achievementsService = ServiceLocator.GetService <AchievementsService>();
            _audioService        = ServiceLocator.GetService <AudioService>();
            _levelService        = ServiceLocator.GetService <LevelService>();
            _adsService          = ServiceLocator.GetService <AdsService>();
            _skinService         = ServiceLocator.GetService <SkinService>();
            _gameDataService     = ServiceLocator.GetService <GameDataService>();
            _uiService           = ServiceLocator.GetService <UIService>();
            _poolService         = ServiceLocator.GetService <PoolService>();

            Trains          = new List <TrainController>();
            spriteRenderer  = GetComponent <SpriteRenderer>();
            TargetPointList = TargetRail.WayPoints;
            TargetPoint     = TargetPointList[0].localPosition;
            Trains.Add(this);

            InputManager.Swipe      += InputManagerOnSwipe;
            _adsService.TrainRevive += ReviveTrain;
            _uiService.GameRestart  += ResetTrain;

            _skinService.UpdateSkin(spriteRenderer);
            UpdateTrainPoints();
            LockControlls = _uiService.IsFirstTime;
            IsFirstTime   = _uiService.IsFirstTime;
        }
Ejemplo n.º 4
0
 public SpaceLayoutController()
 {
     skinService     = new SkinService();
     userAppService  = new UserAppService();
     visitorService  = new VisitorService();
     menuService     = new UserMenuService();
     siteSkinService = new SiteSkinService();
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets a control to edit the given property</summary>
        /// <param name="context">Context for property editing control</param>
        /// <returns>Control to edit the given context</returns>
        public virtual Control GetEditingControl(PropertyEditorControlContext context)
        {
            NumericTextBox editingControl = new NumericTextBox(m_numericType, context);

            editingControl.ScaleFactor = m_scaleFactor;
            SkinService.ApplyActiveSkin(editingControl);
            return(editingControl);
        }
Ejemplo n.º 6
0
        public SiteInitController()
        {
            skinService = new SkinService();
            skinService.SetSkin(new SpaceSkin());

            feedService = new FeedService();
            pageService = new PageService();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Obtains a control to edit a given property. Changes to the selection set
        /// cause this method to be called again (and passed a new 'context'),
        /// unless ICacheablePropertyControl is implemented on the control. For
        /// performance reasons, it is highly recommended that the control implement
        /// the ICacheablePropertyControl interface.</summary>
        /// <param name="context">Context for property editing control</param>
        /// <returns>Control to edit the given context</returns>
        public virtual Control GetEditingControl(PropertyEditorControlContext context)
        {
            var control = new BoundedIntControl(context, m_min, m_max);

            SkinService.ApplyActiveSkin(control);
            m_controlRefList.RemoveAll(item => !item.IsAlive);
            m_controlRefList.Add(new WeakReference(control));
            return(control);
        }
Ejemplo n.º 8
0
 public ProfileSelectViewModel(
     AccountService accountService,
     SkinService skinService,
     ThemeService themeService)
 {
     _accountService = accountService;
     _skinService    = skinService;
     _themeService   = themeService;
 }
Ejemplo n.º 9
0
        private void SkinServiceSkinChangedOrApplied(object sender, EventArgs e)
        {
            if (IsDisposed)
            {
                return;
            }

            SkinService.ApplyActiveSkin(this);
        }
Ejemplo n.º 10
0
        public NavigationBar()
        {
            DropDownStyle = ComboBoxStyle.DropDownList;
            Sorted        = true;

            m_broker = LuaIntellisenseBroker.Get();

            SkinService.ApplyActiveSkin(this);
            SkinService.SkinChangedOrApplied += SkinServiceSkinChangedOrApplied;
        }
Ejemplo n.º 11
0
    public void Awake()
    {
        _skinService = ServiceLocator.GetService <SkinService>();
        _animator    = _mask.GetComponent <Animator>();

        if (IsUnlocked)
        {
            HideMask(true);
        }
        GetComponent <Button>().onClick.AddListener(SetSkin);
    }
Ejemplo n.º 12
0
 private void TreeControl_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         var instancingContext = m_layerLister.TreeView.As <IInstancingContext>();
         m_deleteLayer.Enabled = instancingContext.CanDelete();
         m_deleteLayer.Visible = instancingContext.CanDelete();
         SkinService.ApplyActiveSkin(m_contextMenuStrip);
         m_contextMenuStrip.Show(m_layerLister.TreeControl, e.X, e.Y);
     }
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Gets a control to edit the given property</summary>
        /// <param name="context">Context for property editing control</param>
        /// <returns>Control to edit the given context</returns>
        public Control GetEditingControl(PropertyEditorControlContext context)
        {
            NumericMatrixControl result =
                new NumericMatrixControl(m_numericType, m_rows, m_columns, context);

            // Controls[0] is the 1st TextBox for 1st matrix element
            // result.Height = result.Controls[0].Font.Height * m_rows + result.Margin.Top + result.Margin.Bottom + 2;
            result.ScaleFactor = m_scaleFactor;
            SkinService.ApplyActiveSkin(result);
            return(result);
        }
Ejemplo n.º 14
0
        public void Initialize()
        {
            BuildControl();

            var mainForm = SledServiceInstance.TryGet <MainForm>();

            mainForm.Shown += MainFormShown;

            SkinService.ApplyActiveSkin(SledTtyMessageColorer.Instance);
            SkinService.SkinChangedOrApplied += SkinServiceSkinChangedOrApplied;
        }
Ejemplo n.º 15
0
        public GroupLayoutController()
        {
            groupMenuService = new GroupMenuService();
            groupAppService  = new GroupAppService();

            groupService    = new GroupService();
            mgrService      = new MemberGroupService();
            gfService       = new GroupFriendService();
            skinService     = new SkinService();
            siteSkinService = new SiteSkinService();
        }
Ejemplo n.º 16
0
 protected override void OnMouseUp(MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         var instancingContext = TreeView.As <IInstancingContext>();
         m_deleteBookmark.Enabled = instancingContext.CanDelete();
         m_deleteBookmark.Visible = instancingContext.CanDelete();
         SkinService.ApplyActiveSkin(m_contextMenuStrip);
         m_contextMenuStrip.Show(TreeControl, e.X, e.Y);
     }
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Gets a control to edit the given property</summary>
        /// <param name="context">Context for property editing control</param>
        /// <returns>Control to edit the given context</returns>
        public Control GetEditingControl(PropertyEditorControlContext context)
        {
            InVectorControl editingControl =
                new InVectorControl(m_numericType, m_names, context);

            editingControl.Height        = editingControl.Font.Height + 2;
            editingControl.ScaleFactor   = m_scaleFactor;
            editingControl.HideAxisLabel = HideAxisLabel;
            editingControl.SetLabelBackColors(m_labelColors);
            SkinService.ApplyActiveSkin(editingControl);
            return(editingControl);
        }
Ejemplo n.º 18
0
        public void TestSkinningNonControls()
        {
            var skinService = new SkinService();
            var generalA    = new GeneralObjectA();

            skinService.OpenSkinFile(".\\Resources\\TestSkin.xml");
            skinService.ApplyActiveSkin();
            SkinService.ApplyActiveSkin(generalA);
            Assert.IsTrue(generalA.StringA == "TestSkinValueA");
            skinService.ResetSkin();
            Assert.IsTrue(generalA.StringA == null);
        }
Ejemplo n.º 19
0
        private void ApplySkin()
        {
            foreach (var frm in m_lstForms)
            {
                SkinService.ApplyActiveSkin(frm.Control);
            }

            var mode = Mode;

            ChangeMode(SledFindAndReplaceModes.None);
            ChangeMode(mode);
        }
Ejemplo n.º 20
0
        public AccountService(
            ConfigService configService,
            SkinService skinService,
            LogService logService,
            HttpClient client)
        {
            _config      = configService.Entries;
            _skinService = skinService;
            _logService  = logService;
            _client      = client;

            _accounts = _config.Accounts;
        }
Ejemplo n.º 21
0
        private void Awake()
        {
            _uiService           = ServiceLocator.GetService <UIService>();
            _playGamesService    = ServiceLocator.GetService <PlayGamesService>();
            _skinService         = ServiceLocator.GetService <SkinService>();
            _achievementsService = ServiceLocator.GetService <AchievementsService>();

            _skinsList = new List <SkinButton>();
            _getRandomSkin.onClick.AddListener(GetRandomSkin);
            _pages.ForEach(page => _skinsList.AddRange(page.GetComponentsInChildren <SkinButton>()));
            _skinService.UpdateSelectedTrainPreview += UpdateSelectedPreview;
            UpdateSkins();
            _selectedTrainPreview.sprite = _skinService.GetCurrentSkin();
        }
Ejemplo n.º 22
0
        private void StartAnalysis(object sender, EventArgs e)
        {
            if (vedioPalyer.IsRunning)
            {
                var image = (Bitmap)vedioPalyer.GetCurrentVideoFrame().Clone();
                image.Save(@"d:\" + Guid.NewGuid().ToString() + ".bmp", ImageFormat.Bmp);

                Dictionary <string, string> result = new Dictionary <string, string>();

                try
                {
                    this.Cursor = Cursors.WaitCursor;

                    SkinService service = new SkinService();

                    var imageResult = service.ProcessImage(SkinTalk.Core.AnalysisType.Human, null, true, (Bitmap)image.Clone());
                    result.Add("肤色", imageResult.Score.ToString());

                    imageResult = service.ProcessImage(SkinTalk.Core.AnalysisType.Inflammation, null, true, (Bitmap)image.Clone());
                    result.Add("炎症", imageResult.Score.ToString());

                    imageResult = service.ProcessImage(SkinTalk.Core.AnalysisType.Mositure, null, true, (Bitmap)image.Clone());
                    result.Add("水分", imageResult.Score.ToString());

                    imageResult = service.ProcessImage(SkinTalk.Core.AnalysisType.Oil, null, true, (Bitmap)image.Clone());
                    result.Add("油脂", imageResult.Score.ToString());

                    imageResult = service.ProcessImage(SkinTalk.Core.AnalysisType.Pigment, null, true, (Bitmap)image.Clone());
                    result.Add("色素", imageResult.Score.ToString());

                    imageResult = service.ProcessImage(SkinTalk.Core.AnalysisType.Pores, null, true, (Bitmap)image.Clone());
                    result.Add("毛孔", imageResult.Score.ToString());

                    imageResult = service.ProcessImage(SkinTalk.Core.AnalysisType.Texture, null, true, (Bitmap)image.Clone());
                    result.Add("纹理", imageResult.Score.ToString());
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }

                ResultForm resultForm = new ResultForm();
                resultForm.StartPosition = FormStartPosition.CenterParent;
                resultForm.ItemResults   = result;
                resultForm.ShowDialog();
            }
        }
Ejemplo n.º 23
0
        public static TScreen FromStream <TScreen>(ContentManager contentManager, Stream stream, params Type[] customControlTypes)
            where TScreen : Screen
        {
            var skinService = new SkinService();
            var serializer  = new GuiJsonSerializer(contentManager, customControlTypes)
            {
                Converters =
                {
                    new SkinJsonConverter(contentManager, skinService, customControlTypes),
                    new ControlJsonConverter(skinService, customControlTypes)
                }
            };

            using (var streamReader = new StreamReader(stream))
                using (var jsonReader = new JsonTextReader(streamReader))
                {
                    var screen = serializer.Deserialize <TScreen>(jsonReader);
                    return(screen);
                }
        }
Ejemplo n.º 24
0
 public ProfileSelectViewModel(SkinService skinService)
 {
     _skinService = skinService;
 }
Ejemplo n.º 25
0
        private static void GotoDefinitions(string title, ILuaIntellisenseDocument document, Func <Expression, List <LuatValue.IReference> > func)
        {
            if ((document == null) ||
                (document.SyntaxEditorControl == null) ||
                (func == null))
            {
                return;
            }

            var se = (ActiproSoftware.SyntaxEditor.SyntaxEditor)document.SyntaxEditorControl;

            if ((se.Document == null) ||
                (se.SelectedView == null))
            {
                return;
            }

            var expression = GetExpressionAt(se.Document, se.SelectedView.Selection.StartOffset);

            if (expression == null)
            {
                return;
            }

            var definitions = func(expression);

            if (definitions == null)
            {
                return;
            }

            if (definitions.Count == 0)
            {
                return;
            }

            if (definitions.Count == 1)
            {
                definitions[0].Goto();
                return;
            }

            using (var gfx = se.SelectedView.CreateGraphics())
            {
                var menu = new ContextMenuStrip {
                    ImageList = LuaIntellisenseIcons.GetImageList()
                };
                SkinService.ApplyActiveSkin(menu);

                KeyValuePair <string, LuatValue.IReference[]>[] groups = definitions.GroupItems(a => a.Context, a => a);

                ToolStripLabel label;
                {
                    label = new ToolStripLabel(title)
                    {
                        Enabled = false
                    };
                    menu.Items.Add(label);
                }

                int index = 0;

                foreach (KeyValuePair <string, LuatValue.IReference[]> group in groups)
                {
                    menu.Items.Add(new ToolStripSeparator());

                    if (groups.Length > 0)
                    {
                        label = new ToolStripLabel("Context: " + group.Key)
                        {
                            Enabled = false
                        };
                        menu.Items.Add(label);
                    }

                    var items = new List <ToolStripItem>();
                    foreach (LuatValue.IReference definition in group.Value)
                    {
                        string text = GetReferenceText(definition, document.Project);
                        string file = System.IO.Path.GetFileName(definition.Path);
                        int    line = definition.Line;

                        LuatValue.GotoReference gotoRef = definition.Goto;
                        var item =
                            new ToolStripMenuItem
                        {
                            ImageIndex =
                                (int)(definition.Value != null
                                                  ? definition.Value.Type.Icon
                                                  : LuaIntellisenseIconType.Unknown),
                            Text = string.Format("&{0} {1}({2}): {3}", index++, file, line, text),
                            Font = se.Font,
                            Tag  = line
                        };
                        item.Width  = (int)gfx.MeasureString(item.Text, item.Font).Width;
                        item.Click += (s, e) => gotoRef();
                        items.Add(item);
                    }

                    menu.Items.AddRange(items.OrderBy(x => (int)x.Tag).ToArray());
                }

                var rect = se.SelectedView.GetCharacterBounds(se.SelectedView.Selection.StartOffset);
                menu.Show(se, rect.Location);
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Opens or creates a document at the given URI.
        /// Creates and configures with control adapters D2dAdaptableControl to display subcircuit</summary>
        /// <param name="uri">Document URI</param>
        /// <returns>Document, or null if the document couldn't be opened or created</returns>
        public IDocument Open(Uri uri)
        {
            DomNode node     = null;
            string  filePath = uri.LocalPath;

            if (File.Exists(filePath))
            {
                // read existing document using standard XML reader
                using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
                {
                    CircuitReader reader = new CircuitReader(m_schemaLoader);
                    node = reader.Read(stream, uri);
                }
            }
            else
            {
                // create new document by creating a Dom node of the root type defined by the schema
                node = new DomNode(Schema.circuitDocumentType.Type, Schema.circuitRootElement);
                // create an empty root prototype folder
                node.SetChild(
                    Schema.circuitDocumentType.prototypeFolderChild,
                    new DomNode(Schema.prototypeFolderType.Type));
            }

            CircuitDocument circuitCircuitDocument = null;

            if (node != null)
            {
                // now that the data is complete, initialize all other extensions to the Dom data
                node.InitializeExtensions();

                AdaptableControl control = CreateCircuitControl(node);
                control.AddHelp("https://github.com/SonyWWS/ATF/wiki/Adaptable-Controls".Localize());

                var viewingContext = node.Cast <ViewingContext>();
                viewingContext.Control = control;

                circuitCircuitDocument = node.Cast <CircuitDocument>();
                string      fileName    = Path.GetFileName(filePath);
                ControlInfo controlInfo = new ControlInfo(fileName, filePath, StandardControlGroup.Center);

                //Set IsDocument to true to prevent exception in command service if two files with the
                //  same name, but in different directories, are opened.
                controlInfo.IsDocument = true;

                circuitCircuitDocument.ControlInfo = controlInfo;
                circuitCircuitDocument.Uri         = uri;

                var editingContext = node.Cast <CircuitEditingContext>();
                editingContext.GetLocalBound       = GetLocalBound;
                editingContext.GetWorldOffset      = GetWorldOffset;
                editingContext.GetTitleHeight      = GetTitleHeight;
                editingContext.GetLabelHeight      = GetLabelHeight;
                editingContext.GetSubContentOffset = GetSubContentOffset;

                control.Context             = editingContext;
                editingContext.SchemaLoader = m_schemaLoader; // schema needed for cut and paste between applications

                m_circuitControlRegistry.RegisterControl(node, control, controlInfo, this);
                SkinService.ApplyActiveSkin(control);
                // Set the zoom and translation to show the existing items (if any).
                var enumerableContext = editingContext.Cast <IEnumerableContext>();
                if (viewingContext.CanFrame(enumerableContext.Items))
                {
                    viewingContext.Frame(enumerableContext.Items);
                }

                //var viewingAdapter = control.As<ViewingAdapter>();
                // enable toggle after initial frame operation.
                //  viewingAdapter.ToggleFramingEnabled = true; // toggle frame/unframe.
            }

            return(circuitCircuitDocument);
        }
Ejemplo n.º 27
0
 /// <summary>
 /// Binds the control to a property editing context</summary>
 /// <param name="context">Context in which properties are edited</param>
 public void Bind(IPropertyEditingContext context)
 {
     m_propertyGridView.EditingContext = context;
     SkinService.ApplyActiveSkin(m_propertyGridView);
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Obtains a control to edit a given property. Changes to the selection set
 /// cause this method to be called again (and passed a new 'context'),
 /// unless ICacheablePropertyControl is implemented on the control. For
 /// performance reasons, it is highly recommended that the control implement
 /// the ICacheablePropertyControl interface.</summary>
 /// <param name="context">Context for property editing control</param>
 /// <returns>Control to edit the given context</returns>
 public Control GetEditingControl(PropertyEditorControlContext context)
 {
     m_boolControl = new BoolControl(context);
     SkinService.ApplyActiveSkin(m_boolControl);
     return(m_boolControl);
 }
Ejemplo n.º 29
0
        public void TestSkinApplying()
        {
            var skinService = new SkinService();

            var   earlyControl      = new TestControlA();
            Color originalBackColor = earlyControl.BackColor;

            SkinService.ApplyActiveSkin(earlyControl);

            skinService.OpenSkinFile(".\\Resources\\TestSkin.xml");

            // The new value should not be applied yet.
            Assert.IsTrue(earlyControl.BackColor == originalBackColor);

            skinService.ApplyActiveSkin();

            // The new color should be applied now. http://tracker.ship.scea.com/jira/browse/WWSATF-1028
            Assert.IsTrue((uint)earlyControl.BackColor.ToArgb() == 0xff00000a);

            var controlA = new TestControlA();

            SkinService.ApplyActiveSkin(controlA);
            Assert.IsTrue((uint)controlA.BackColor.ToArgb() == 0xff00000a);
            Assert.IsTrue(string.Equals(controlA.StringA, "TestSkinValueA"));

            var controlB = new TestControlB();

            SkinService.ApplyActiveSkin(controlB);
            Assert.IsTrue((uint)controlB.BackColor.ToArgb() == 0xff00000b);
            Assert.IsTrue(string.Equals(controlB.StringA, "TestSkinValueA"));
            Assert.IsTrue(string.Equals(controlB.StringB, "TestSkinValueB"));

            var controlC = new TestControlC();

            SkinService.ApplyActiveSkin(controlC);
            Assert.IsTrue((uint)controlC.BackColor.ToArgb() == 0xff00000c);
            Assert.IsTrue(string.Equals(controlC.StringA, "TestSkinValueA"));
            Assert.IsTrue(string.Equals(controlC.StringB, "TestSkinValueB"));
            Assert.IsTrue(string.Equals(controlC.StringC, "TestSkinValueC"));

            var controlX = new TestControlX();

            SkinService.ApplyActiveSkin(controlX);
            Assert.IsTrue(string.Equals(controlX.StringA, "TestSkinValueX"));

            var controlY = new TestControlY();

            SkinService.ApplyActiveSkin(controlY);
            Assert.IsTrue(string.Equals(controlY.StringA, "TestSkinValueY"));

            var controlZ = new TestControlZ();

            SkinService.ApplyActiveSkin(controlZ);
            Assert.IsTrue(string.Equals(controlZ.StringA, "TestSkinValueZ"));

            //DerivedUndefinedControl derives from TestControlC, so should receive C's style
            var undefinedControl = new DerivedUndefinedControl();

            SkinService.ApplyActiveSkin(undefinedControl);
            Assert.IsTrue((uint)undefinedControl.BackColor.ToArgb() == 0xff00000c);
            Assert.IsTrue(string.Equals(undefinedControl.StringA, "TestSkinValueA"));
            Assert.IsTrue(string.Equals(undefinedControl.StringB, "TestSkinValueB"));
            Assert.IsTrue(string.Equals(undefinedControl.StringC, "TestSkinValueC"));

            // Make sure that the skins are reset correctly.
            skinService.ResetSkin(); //sets the active skin to null
            Assert.IsTrue(controlA.BackColor == originalBackColor);
            Assert.IsTrue(controlA.StringA == null);

            Assert.IsTrue(controlB.BackColor == originalBackColor);
            Assert.IsTrue(controlB.StringA == null);
            Assert.IsTrue(controlB.StringB == null);

            Assert.IsTrue(controlC.BackColor == originalBackColor);
            Assert.IsTrue(controlC.StringA == null);
            Assert.IsTrue(controlC.StringB == null);
            Assert.IsTrue(controlC.StringC == null);

            Assert.IsTrue(undefinedControl.BackColor == originalBackColor);
            Assert.IsTrue(undefinedControl.StringA == null);
            Assert.IsTrue(undefinedControl.StringB == null);
            Assert.IsTrue(undefinedControl.StringC == null);

            // Apply the skin again, this time with new original values.
            // To-do: it's kind of odd that we have to reload the xml file. What if clients wanted to rapidly
            //  switch back and forth programmatically?
            controlA.StringA         = "OriginalA";
            controlB.StringB         = "OriginalB";
            controlC.StringC         = "OriginalC";
            undefinedControl.StringC = "OriginalC";
            skinService.OpenSkinFile(".\\Resources\\TestSkin.xml");
            skinService.ApplyActiveSkin();
            SkinService.ApplyActiveSkin(controlA);
            SkinService.ApplyActiveSkin(controlB);
            SkinService.ApplyActiveSkin(controlC);
            SkinService.ApplyActiveSkin(undefinedControl);
            skinService.ResetSkin();
            Assert.IsTrue(controlA.StringA == "OriginalA");
            Assert.IsTrue(controlB.StringB == "OriginalB");
            Assert.IsTrue(controlC.StringC == "OriginalC");
            Assert.IsTrue(undefinedControl.StringC == "OriginalC");
        }
        // Rebuild all item controls when the selected collection object has changed
        private void RebuildItemControls(object collectionObject)
        {
            m_activeCollectionNode = collectionObject;
            var array = m_context.Descriptor.GetValue(m_context.LastSelectedObject) as Array;

            m_lastKnownSize = array.Length;

            // Set index column width to be big enough to display the highest expected index,
            // using double the number of current items as first estimate.
            // This could be done more accurately with MeasureString and could also be dynamically
            // adjusted if the number exceeds the current max due to add operations.
            m_indexColumnWidth = Math.Max(30, (array.Length * 2).ToString().Length * 10);

            try
            {
                SuspendLayout();

                m_toolStrip.Enabled = false;

                // Clear and dispose all current item controls
                foreach (ItemControl itemControl in m_itemControls.Values)
                {
                    UnsubscribeItemEvents(itemControl);
                    Controls.Remove(itemControl);
                    itemControl.Dispose();
                }
                m_itemControls.Clear();


                // Add controls for added items
                // Currently only adding at the end is supported. If we ever want to support
                // inserting in the middle, then we'd probably want to have this step before
                // the index-reordering one.
                int top           = m_toolStrip.Height;
                var controlsToAdd = new List <ItemControl>();
                int id            = 0;
                foreach (object item in array)
                {
                    // Work around for a very strange bug related to the parent Control having a custom font.
                    // It seems to be important to not have this ItemControl's Font property set when adding
                    //  it to our Controls, in the call to Controls.AddRange() below.
                    // The parent Control is probably a Sce.Atf.Controls.PropertyEditing.PropertyGridView.
                    // See this tracker item: http://tracker.ship.scea.com/jira/browse/CORETEXTEDITOR-363
                    Font defaultFont = (Parent != null) ? Parent.Font : Font;

                    var itemControl = new ItemControl(m_itemControls.Count, item, m_indexColumnWidth)
                    {
                        Width  = m_toolStrip.Width,
                        Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
                        Top    = top,
                        Index  = id,
                        Font   = defaultFont
                    };

                    top += itemControl.Height;
                    m_itemControls.Add(id, itemControl);
                    controlsToAdd.Add(itemControl);
                    SubscribeItemEvents(itemControl);
                    id++;
                }
                Controls.AddRange(controlsToAdd.ToArray());

                Height = top; // update height of main collection control

                UpdateAddButton();
                UpdateDeleteButton(true);
                UpdateMoveButtons(true);
            }
            catch (Win32Exception ex)
            {
                // For very large collections (with 1000+ items) it is possible that Windows runs out of Window handles
                // Such collections are currently not usable with this editor. To support such collections we'd have to
                // implement some kind of virtual mode (i.e. stream items in and out) but that would pose some new
                // challenges for editing operations (add, remove, move)

                // Clean up to release some window handles and keep the application running smoothly
                foreach (ItemControl control in m_itemControls.Values)
                {
                    if (Controls.Contains(control))
                    {
                        Controls.Remove(control);
                    }
                    control.Dispose();
                }
                m_itemControls.Clear();

                // Report error. Must be done after cleaning up, as before we may not even have the resources to show the message box.
                MessageBox.Show(
                    "Failed to create item controls, probably because there were not enough Window handles available. Consider using a different editor for collections of this size and nature.\r\n\r\n"
                    + ex.GetType().ToString() + Environment.NewLine
                    + ex.Message,
                    "Failed to create item controls", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                ResumeLayout();
                m_toolStrip.Enabled = true;
            }

            SkinService.ApplyActiveSkin(this);
            // refreshes alternate back color for even/odd selected items.
            foreach (ItemControl control in m_itemControls.Values)
            {
                control.Selected = control.Selected;
            }
        }