Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the DetailBar class.
        /// </summary>
        public DetailBar()
        {
            // The data context drives the information that is presented in this control.
            this.DataContextChanged += new DependencyPropertyChangedEventHandler(OnDataContextChanged);

            // When the size of the frame changes we need to adjust the settings on the grid to make sure that everything important stays visible.
            this.SizeChanged += new SizeChangedEventHandler(this.OnSizeChanged);

            // This is the collection of items that appear in the metadata area.
            this.items = new ViewableCollection();

            // The actual detail area is composed of two collections.  One is basically a 'system' area where metadata common to all objects is displayed, such as
            // the name of the element and the element's type.  The second part is filled in with data provided by the consumer of the DetailBar.  In most
            // scenarios, this is the ExplorerFrame window which, in turn is fed metadata by an embedded page.  However, the DetailBar doesn't want to make a
            // distinction between the two lists when presenting the information in the WrapPanel: both collections are aggregated and treated as a single list.
            CompositeCollection compositCollection = new CompositeCollection();

            compositCollection.Add(new CollectionContainer()
            {
                Collection = this.commonMetadata
            });
            compositCollection.Add(new CollectionContainer()
            {
                Collection = this.items
            });
            base.ItemsSource = compositCollection;
        }
Exemplo n.º 2
0
        public static Synchronizer <Ta, Tb> SyncWith <Ta, Tb>(this ViewableCollection <Ta> collectionA, IEnumerable <Tb> collectionB, Func <Tb, Ta> createA, Action <Ta> destroyA = null, Predicate <Tb> filterPredicate = null, SyncEventHandler <Ta, Tb> syncEventHandler = null)
        {
            var target = new ViewableCollectionTarget <Ta>(collectionA);
            var source = CreateGenericSource(collectionB);

            destroyA        = destroyA ?? RemoveAndDispose;
            filterPredicate = filterPredicate ?? DefaultFilterPredicate;
            return(new Synchronizer <Ta, Tb>(target, source, createA, destroyA, filterPredicate, syncEventHandler));
        }
Exemplo n.º 3
0
 protected virtual void OnDisconnected(IPin otherPin)
 {
     // Clear cache
     FConnectedPins = null;
     if (FDisconnected != null)
     {
         FDisconnected(this, new PinConnectionEventArgs(otherPin));
     }
 }
Exemplo n.º 4
0
        private ViewableCollection <IPin2> InitPins()
        {
            var pins = new ViewableCollection <IPin2>();

            foreach (var internalPin in FInternalCOMInterf.GetPins())
            {
                var pin = Pin.Create(this, internalPin, FNodeInfoFactory);
                pins.Add(pin);
            }
            return(pins);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the GadgetBar class.
        /// </summary>
        public GadgetBar()
        {
            // The PanelItems is an ObservableCollection that is used by the GadgetPanel to communicate with the panel.  It describes which of the child items of
            // this contol are visible on the panel and therefore, should be logical children of the GadgetBar.  When items can't fit onto the panel during the
            // measurement pass (or are forced there through properties), they are given to the overflow item which then becomes the logical parent.  Since only a
            // parent can give up logical control, the PanelItems list is used to basically ask the GadgetBar to add and remove logical children as the panel
            // measures itself.  However, the VisibleCollection has a flaw for this purpose: by the time the 'Reset' event is handled, all the items have been
            // expunged from the list.  This parallel list of items is used to handle the 'Reset'.
            this.childList = new List <Object>();

            // This observable collections is used to communicate the set of logical children that are associated with the visible panel.  As items are added or
            // removed from the collection, so are they added or removed as logical children of this control.  This is necessary so that menu items can pick up the
            // role attribute that goes along with the parent menu.  For example, if a menu item is placed on the top level (visible) panel, then it should have a
            // down-arrow glyph to indicate that it has child items.  If that same menu item is moved to an overflow panel because it can't fit in the visible
            // panel, it is now a submenu and should have a right or left arrow to indicate children.  This is only possible when the item has the proper logical
            // connection to the parent menu or overflow control.
            this.SetValue(GadgetBar.panelItemsPropertyKey, new ObservableCollection <Object>());

            // This event handler will add or remove logical children to this control.  The GadgetPanel will manage the contents of the list because it knows
            // what can fit and what needs to be put into the overflow panel.  This control will use the collection to add and remove the logical children.
            this.PanelItems.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnPanelItemsPropertyChanged);

            // All GadgetBars have an implicit OverflowItem control where items that don't fit onto the main panel are moved.
            this.overflowItem = new OverflowItem();

            // IMPORTANT CONCEPT: every GadgetBar has an implicit overflow menu item that catches the items that don't fit into the panel.  This item must be part
            // of the 'Items' in an ItemsControl for the keyboard navigation to work.  Internally, the WPF base classes have a dependency on the
            // ItemsContainerGenerator that is not obvious.  The overflow item can't be added as a stand-alone element in the panels where the items are displayed
            // if the navigation keys are to work.  So far, so good.  But how do you create an implicit item for an items control?  In this design it is a
            // ViewableCollection (functionally equivalent to an ItemsCollection but without the connection to the FrameworkElements) that is combined with the
            // overflow item to make a composite collection.  The composite collection is then joined to the SourceItems of the underlying ItemsControl.  The user
            // of this control only ever sees the 'Items' and the 'ItemsSource'.
            this.items = new ViewableCollection();

            // The Composite collection is where the implicit overflow item is merged with the collection of items available to the user of this control.  This
            // design makes the API to the consumer of this control appear to be a standard ItemsControl, but allows us to add an implicit overflow item that
            // can not be manipulated directly by the consumer yet feeds into the ItemsContainerGenerator like any other item in the GadgetBar.
            this.compositCollection = new CompositeCollection();
            this.compositCollection.Add(this.overflowItem);
            this.compositCollection.Add(new CollectionContainer()
            {
                Collection = this.items
            });
            base.ItemsSource = this.compositCollection;
        }
Exemplo n.º 6
0
        public void TestGenericListAndViewableCollection()
        {
            var sampleData       = GenerateSampleData(10);
            var sourceCollection = new ViewableCollection <int>();
            var targetCollection = new List <int>();

            var syncer = targetCollection.SyncWith(sourceCollection, (itemB) => itemB);

            sourceCollection.AddRange(sampleData);

            CollectionAssert.AreEqual(sourceCollection, targetCollection);

            sourceCollection.Remove(sampleData[0]);

            CollectionAssert.AreEqual(sourceCollection, targetCollection);

            sourceCollection.Clear();

            CollectionAssert.AreEqual(sourceCollection, targetCollection);
        }
Exemplo n.º 7
0
        public void TestEditableCollectionAndViewableCollection()
        {
            var sampleData       = GenerateSampleData(10);
            var sourceCollection = new ViewableCollection <int>();
            IEditableCollection <int> targetCollection = new EditableCollection <int>();

            var syncer = targetCollection.SyncWith(sourceCollection, (itemB) => itemB);

            sourceCollection.AddRange(sampleData);

            CollectionAssert.AreEqual(sourceCollection, targetCollection);

            sourceCollection.Remove(sampleData[0]);

            CollectionAssert.AreEqual(sourceCollection, targetCollection);

            // Make sure a Clear triggers following event chaing: UpdateBegun / Removed ... / Cleared / Updated
            int updateBegunCount = 0;

            sourceCollection.UpdateBegun += delegate(IViewableCollection collection) { updateBegunCount++; };
            int removedCount = 0;
            int removeCount  = sourceCollection.Count;

            sourceCollection.Removed += delegate(IViewableCollection <int> collection, int item) { removedCount++; };
            int clearedCount = 0;

            sourceCollection.Cleared += delegate(IViewableCollection <int> collection) { clearedCount++; };
            int updatedCount = 0;

            sourceCollection.Updated += delegate(IViewableCollection collection) { updatedCount++; };

            sourceCollection.Clear();

            Assert.AreEqual(1, updateBegunCount);
            Assert.AreEqual(1, updatedCount);
            Assert.AreEqual(removeCount, removedCount);
            Assert.AreEqual(1, clearedCount);

            CollectionAssert.AreEqual(sourceCollection, targetCollection);
        }
Exemplo n.º 8
0
        public CodeEditorPlugin(IHDEHost host, INode node, ISolution solution, ILogger logger)
        {
            FHDEHost   = host;
            FNode      = node;
            FSolution  = solution;
            FLogger    = logger;
            FErrorList = new ViewableCollection <object>();

            if (CompletionIcons.Images.Count == 0)
            {
                var resources = new ComponentResourceManager(typeof(CodeEditorPlugin));
                CompletionIcons.TransparentColor = System.Drawing.Color.Transparent;
                CompletionIcons.Images.Add((System.Drawing.Bitmap)resources.GetObject("Icons.16x16.Class"));
                CompletionIcons.Images.Add((System.Drawing.Bitmap)resources.GetObject("Icons.16x16.Method"));
                CompletionIcons.Images.Add((System.Drawing.Bitmap)resources.GetObject("Icons.16x16.Property"));
                CompletionIcons.Images.Add((System.Drawing.Bitmap)resources.GetObject("Icons.16x16.Field"));
                CompletionIcons.Images.Add((System.Drawing.Bitmap)resources.GetObject("Icons.16x16.Enum"));
                CompletionIcons.Images.Add((System.Drawing.Bitmap)resources.GetObject("Icons.16x16.NameSpace"));
                CompletionIcons.Images.Add((System.Drawing.Bitmap)resources.GetObject("Icons.16x16.Event"));

                var path     = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"..\..\thirdparty"));
                var provider = new SD.FileSyntaxModeProvider(path);
                SD.HighlightingManager.Manager.AddSyntaxModeFileProvider(provider);
            }

            SuspendLayout();

            FCodeEditorForm                     = new Form();
            FCodeEditorForm.Location            = new Point(0, 0);
            FCodeEditorForm.TopLevel            = false;
            FCodeEditorForm.TopMost             = false;
            FCodeEditorForm.Dock                = DockStyle.Fill;
            FCodeEditorForm.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            FCodeEditorForm.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
            FCodeEditorForm.BackColor           = System.Drawing.Color.Silver;
            FCodeEditorForm.ClientSize          = new System.Drawing.Size(881, 476);
            FCodeEditorForm.ControlBox          = false;
            FCodeEditorForm.FormBorderStyle     = System.Windows.Forms.FormBorderStyle.None;
            FCodeEditorForm.MaximizeBox         = false;
            FCodeEditorForm.MinimizeBox         = false;
            FCodeEditorForm.ShowIcon            = false;
            FCodeEditorForm.ShowInTaskbar       = false;
            FCodeEditorForm.SizeGripStyle       = System.Windows.Forms.SizeGripStyle.Hide;
            FCodeEditorForm.TopMost             = true;
            FCodeEditorForm.Show();

            FEditor      = new CodeEditor(FCodeEditorForm, FLogger);
            FEditor.Dock = DockStyle.Fill;
            FCodeEditorForm.Controls.Add(FEditor);

            FErrorTableViewer              = new TableViewer();
            FErrorTableViewer.Dock         = DockStyle.Bottom;
            FErrorTableViewer.TabIndex     = 0;
            FErrorTableViewer.DoubleClick += FErrorTableViewerDoubleClick;
            FErrorTableViewer.AutoSize     = true;
            FErrorTableViewer.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            FErrorTableViewer.MaximumSize  = new Size(0, 100);

            Controls.Add(FCodeEditorForm);
            Controls.Add(FErrorTableViewer);

            ResumeLayout(false);
            PerformLayout();

            var registry = new MappingRegistry();

            registry.RegisterDefaultMapping <IEnumerable <Column>, ErrorCollectionColumnProvider>();
            registry.RegisterMapping <CompilerError, IEnumerable <ICell>, ErrorCellProvider>();
            registry.RegisterMapping <RuntimeError, IEnumerable <ICell>, RuntimeErrorCellProvider>();

            FErrorTableViewer.Registry = registry;
            FErrorTableViewer.Input    = FErrorList;

            FEditor.LinkClicked += FEditor_LinkClicked;
        }
Exemplo n.º 9
0
 public ViewableCollectionTarget(ViewableCollection <T> collection)
 {
     FCollection = collection;
 }
 public MyViewModel()
 {
     this.Collection1 = new ViewableCollection <MySecondViewModel>();
 }