/// <summary>
        /// Map selection changed, update the cable choices
        /// </summary>
        void helper_ActiveViewSelectionChanged()
        {
            // Window not fully initialized or visible.
            if (!this.Visible || _connectionHelper == null)
            {
                return;
            }

            try
            {
                // Save changes option if the selection change with unsaved edits.
                if (btnSave.Enabled)
                {
                    FeatureWrapper from = cboFrom.SelectedItem as FeatureWrapper;
                    FeatureWrapper to   = cboTo.SelectedItem as FeatureWrapper;

                    IsUserSure(from, to);
                }

                // Populate with new information
                ClearGrid();
                PopulateDropDowns(_connectionHelper);
                List <Connection> list = getConnections();
                LoadExistingRecords(list);
            }
            catch (Exception e)
            {
                MessageBox.Show("Error gathering connection information: \n" + e.ToString());
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructs a leaf node from the given parameters.
        /// A reference to the features list is kept, so do not
        /// modify the list after constructing this node.
        /// </summary>
        /// <param name="features">The features at this node.</param>
        /// <param name="offsetsToTest">Any remaining offests to test before returning matches.</param>
        public LeafFeatureTreeNode(FeatureWrapper feature, List<Point> offsetsToTest)
        {
            FeatureWithHotspot = feature;

            OffsetsToTest = GetOffsets(feature, offsetsToTest);

        }
Exemplo n.º 3
0
        public MFFeatureTreeNode(FeatureWrapper feature)
            : base (feature.Name, ImageKeysEnum.Feature)
        {
            this.Feat = feature;
            this.Tag = feature;

        }
Exemplo n.º 4
0
        protected IEventComponent ShowFeatureEditorByGuid(string guid)
        {
            bool exist = false;

            foreach (DockContent item in DockPanel.Contents)
            {
                if (item.GetType() == typeof(FeatureEditor))
                {
                    FeatureEditor editor = (FeatureEditor)item;
                    if (editor.Feature.Guid == guid)
                    {
                        editor.Show();
                        exist = true;
                    }
                }
            }

            if (!exist)
            {
                FeatureWrapper feat = PK.Wrapper.FindFeature(guid);
                if (feat != null)
                {
                    FE = new FeatureEditor();
                    FE.OpenContainingFolderEvent += new EventHandler <Forms.BaseForms.PathEventArgs>(OpenContainingFolderEvent);
                    FE.SetFeat(feat);
                    FE.Show(DockPanel, DockState.Document);
                    return(FE);
                }
            }
            return(null);
        }
Exemplo n.º 5
0
        public DocumentationPage(FeatureWrapper Feat)
            : base(Feat)
        {
            InitializeComponent();

            HeaderLbl.Text = this.NodeName;
        }
Exemplo n.º 6
0
        public DocumentationPage(FeatureWrapper Feat)
            : base(Feat)
        {
            InitializeComponent();

            HeaderLbl.Text = this.NodeName;
        }
Exemplo n.º 7
0
 public FlagsPage(FeatureWrapper Feat)
     : base(Feat)
 {
     InitializeComponent();
     this.NodeName  = Strings.Flags;
     HeaderLbl.Text = this.NodeName;
 }
Exemplo n.º 8
0
 public FilterPage(FeatureWrapper Feat)
     : base(Feat)
 {
     InitializeComponent();
     this.NodeName = Strings.Filter;
     HeaderLbl.Text = this.NodeName;
 }
Exemplo n.º 9
0
        /// <summary>
        /// Returns true if every feature has the same value at the given offset relative to their hotspot.
        /// </summary>
        /// <param name="features">The features to check.</param>
        /// <param name="offset">The offsets to try.</param>
        /// <returns>True if every feature has the same value at the given offset relative to their hotspot.</returns>
        private static bool EveryFeatureIsTheSameAtOffset(List <FeatureWrapper> features, Point offset)
        {
            FeatureWrapper representative = features[0];

            int   pixelValue    = Feature.TRANSPARENT_VALUE;
            Point offsetToCheck = new Point(offset.X + representative.HotspotX,
                                            offset.Y + representative.HotspotY);


            if (Bitmap.OffsetIsInBounds(representative.Feature.Bitmap, offsetToCheck))
            {
                pixelValue = representative.Feature.Bitmap[offsetToCheck.Y, offsetToCheck.X];
            }


            for (int i = 1; i < features.Count; i++)
            {
                int   nextFeaturePixelValue    = Feature.TRANSPARENT_VALUE;
                Point nextFeatureOffsetToCheck = new Point(offset.X + features[i].HotspotX,
                                                           offset.Y + features[i].HotspotY);

                if (Bitmap.OffsetIsInBounds(features[i].Feature.Bitmap, nextFeatureOffsetToCheck))
                {
                    nextFeaturePixelValue = features[i].Feature.Bitmap[nextFeatureOffsetToCheck.Y, nextFeatureOffsetToCheck.X];
                }

                if (pixelValue != nextFeaturePixelValue)
                {
                    return(false);
                }
            }

            return(true);
        }
        /// <summary>
        /// Prompts the user about saving pending edits
        /// </summary>
        /// <param name="fromFtWrapper"></param>
        /// <param name="toFtWrapper"></param>
        /// <returns>False if the user chooses to cancel what they were doing; True if they choose Yes or No
        /// (which means they are OK with what they are doing)</returns>
        private bool IsUserSure(FeatureWrapper fromFtWrapper, FeatureWrapper toFtWrapper)
        {
            bool result = true;

            // Assume they do not want to save and do want to continue
            DialogResult dialogResult = DialogResult.No;

            dialogResult = MessageBox.Show("You have unsaved edits. Would you like to save them before closing?", "Connection Editor", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (DialogResult.Cancel == dialogResult)
            {
                // The user isn't sure about what they are doing and wants to cancel it
                result = false;
            }
            else if (DialogResult.Yes == dialogResult)
            {
                // The user wants to save -- give it a shot
                bool isSaveOk = SaveChanges(fromFtWrapper, toFtWrapper);
                if (!isSaveOk)
                {
                    // They wanted to save but it didn't work. They probably got a message telling them what to fix. Cancel
                    // whatever they were doing so that they have a chance to do so
                    result = false;
                }
            }

            return(result);
        }
Exemplo n.º 11
0
        private void UpdateForm(FeatureWrapper Feat)
        {
            FormText         = Strings.Feature + " : " + Feat.Name;
            ModifiedFormText = FormText + "*";

            this.Feat = Feat;
            if (Feat.Filter == null)
            {
                Feat.Filter = "";
            }

            this.Pages.Clear();

            this.Pages.Add(new Editors.Pages.Feature.MainPage(Feat));
            this.Pages.Add(new Editors.Pages.DescriptionPage(Feat));
            this.Pages.Add(new Editors.Pages.DocumentationPage(Feat));
            this.Pages.Add(new Editors.Pages.Feature.FilterPage(Feat));
            this.Pages.Add(new Editors.Pages.Feature.FlagsPage(Feat));
            this.Pages.Add(new Editors.Pages.Feature.ComponentDependenciesPage(Feat));
            this.Pages.Add(new Editors.Pages.Feature.FeatureDependenciesPage(Feat));


            this.Initialize();

            SetModified(false);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Ru: Открывает редактор для объекта. Если такой уже открыт, то показывает его
        /// En: If object editor has been shown, opens it. I it has not been shown , creates it
        /// </summary>
        /// <param name="obj"></param>
        public void ShowEditor(object obj)
        {
            IEventComponent component = null;

            if (obj is LibraryWrapper)
            {
                LibraryWrapper library = (LibraryWrapper)obj;
                component = ShowLibraryEditorByGuid(library.Guid);
            }
            else if (obj is FeatureWrapper)
            {
                FeatureWrapper feature = (FeatureWrapper)obj;
                component = ShowFeatureEditorByGuid(feature.Guid);
            }
            else if (obj is LibraryCategoryWrapper)
            {
                LibraryCategoryWrapper libcat = (LibraryCategoryWrapper)obj;
                component = ShowLibraryCategoryEditorByGuid(libcat.Guid);
            }
            else if (obj is ComponentWrapper)
            {
                ComponentWrapper comp = (ComponentWrapper)obj;
                switch (comp.ComponentType)
                {
                case ComponentTypeWrapper.Library:
                    component = ShowLibraryEditorByGuid(comp.Guid);
                    break;

                case ComponentTypeWrapper.Feature:
                    component = ShowFeatureEditorByGuid(comp.Guid);
                    break;

                case ComponentTypeWrapper.LibraryCategory:
                    component = ShowLibraryCategoryEditorByGuid(comp.Guid);
                    break;

                default:
                    break;
                }
            }
            else if (obj is BuildFileWrapper)//En: Need to open file editor Ru: Нужно отрыть редактор файлов
            {
                BuildFileWrapper file = (BuildFileWrapper)obj;
                if (!string.IsNullOrEmpty(file.FullPath) && (File.Exists(file.FullPath)))
                {
                    OpenTextEditor(file.FullPath);
                }
            }
            else if (obj is EditFileDescriptor)
            {
                EditFileDescriptor file   = (EditFileDescriptor)obj;
                SourceFileEditor   editor = OpenTextEditor(file.Path);
                if (editor != null)
                {
                    editor.GotoLine(file.Line - 1);
                }
            }
            OnShowEditor(component);
        }
        internal override void SetTypeSpecificData(FeatureWrapper feature,
                                                   IDictionary <string, string> propNameToFieldName, BaseFeature baseFeature)
        {
            var data = baseFeature as PolygonFeature;

            feature.Set(propNameToFieldName[nameof(data.Area)], data.Area);
            feature.SetPolygonGeo(data.Geometry);
        }
        /// <summary>
        /// The link to flash the feature has been clicked
        /// </summary>
        private void lblFlashFrom_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            FeatureWrapper wrapper = cboExisting.SelectedItem as FeatureWrapper;

            if (null != wrapper)
            {
                _fiberTraceHelper.FlashFeature(wrapper.Feature);
            }
        }
        /// <summary>
        /// The flash link was clicked
        /// </summary>
        private void lblFlashSplice_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            FeatureWrapper wrapper = cboSpliceClosure.SelectedItem as FeatureWrapper;

            if (null != wrapper)
            {
                _hookHelper.FlashFeature(wrapper.Feature);
            }
        }
        /// <summary>
        /// The form is closing; check for unsaved edits to the grid
        /// </summary>
        private void ConnectionEditorForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (btnSave.Enabled)
            {
                FeatureWrapper from = cboFrom.SelectedItem as FeatureWrapper;
                FeatureWrapper to   = cboTo.SelectedItem as FeatureWrapper;

                e.Cancel = !IsUserSure(from, to);
            }
        }
Exemplo n.º 17
0
        public FeatureWrapper GetNextFeature()
        {
            var feature = _ogrLayer.GetNextFeature();

            if (feature == null)
            {
                return(null);
            }

            var featureWrapper = new FeatureWrapper(feature);

            return(featureWrapper);
        }
Exemplo n.º 18
0
        protected BaseWrapper[] GetFeatures()
        {
            List <BaseWrapper> feats = new List <BaseWrapper>();

            foreach (ComponentWrapper comp in this.TypedContent.Features)
            {
                FeatureWrapper feat = PK.Wrapper.FindFeature(comp.Guid);
                if (feat != null)
                {
                    feats.Add(ComponentWrapper.GetComponentWrapper(feat));
                }
            }
            return(feats.ToArray());
        }
Exemplo n.º 19
0
        /// <summary>
        /// Return any offsets that are not transparent.
        /// </summary>
        /// <param name="feature">The feature to check.</param>
        /// <param name="offsetsToTest">The offsets to check.</param>
        /// <returns>Any offets that are not transparent.</returns>
        private List<Point> GetOffsets(FeatureWrapper featurewrapper, List<Point> offsetsToTest)
        {
            List<Point> nonTransparents = new List<Point>();
            foreach (Point offset in offsetsToTest)
            {
				int translatedOffsetToTestX = offset.X +  featurewrapper.HotspotX;
				int translatedOffsetToTestY = offset.Y + featurewrapper.HotspotY;
				Point translatedOffsetToTest = new Point(translatedOffsetToTestX, translatedOffsetToTestY);
				if (Bitmap.OffsetIsInBounds(featurewrapper.Feature.Bitmap, translatedOffsetToTest) 
					&& featurewrapper.Feature.Bitmap[translatedOffsetToTest.Y, translatedOffsetToTest.X] != Features.Feature.TRANSPARENT_VALUE)
                    nonTransparents.Add(offset);
            }

            return nonTransparents;
        }
Exemplo n.º 20
0
 private void ShowDescription(FeatureWrapper feature)
 {
     DescriptionTB.Clear();
     DescriptionTB.AppendText("Name: " + feature.Name + "\r\n\r\n");
     DescriptionTB.AppendText("Project Path:\r\n");
     DescriptionTB.AppendText(feature.ProjectPath + "\r\n\r\n");
     DescriptionTB.AppendText("Required: " + feature.Required + "\r\n\r\n");
     DescriptionTB.AppendText("Solution Wizard Visible: " + feature.IsSolutionWizardVisible + "\r\n\r\n");
     if (!string.IsNullOrEmpty(feature.Filter))
     {
         DescriptionTB.AppendText("Filter: " + feature.Filter + "\r\n\r\n");
     }
     DescriptionTB.AppendText("Description:\r\n");
     DescriptionTB.AppendText(feature.Description + "\r\n\r\n");
 }
        /// <summary>
        /// A "to" item has been selected; load the grid
        /// </summary>
        private void cboTo_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!_isReverting)
            {
                bool isChangeAccepted = !btnSave.Enabled; // If the save button is disabled, there is no reason to cancel the change

                if (!isChangeAccepted)
                {
                    // Get the current from feature and the to feature that was selected before the index changed, so we can
                    // prompt for unsaved edits
                    FeatureWrapper from        = cboFrom.SelectedItem as FeatureWrapper;
                    FeatureWrapper preChangeTo = null;
                    if (-1 < _lastSelectedToIdx &&
                        _lastSelectedToIdx < cboTo.Items.Count)
                    {
                        preChangeTo = cboTo.Items[_lastSelectedToIdx] as FeatureWrapper;
                    }

                    isChangeAccepted = IsUserSure(from, preChangeTo);
                }

                if (isChangeAccepted)
                {
                    // The change is committed
                    _lastSelectedToIdx = cboTo.SelectedIndex;

                    if (null != cboFrom.SelectedItem &&
                        null != cboTo.SelectedItem)
                    {
                        UpdateAvailableRanges();

                        // Get the ranges and connections based on whether we are port-strand or strand-port
                        List <Connection> connections = getConnections();

                        LoadExistingRecords(connections);
                    }
                }
                else
                {
                    // Reselect the previous choice
                    _isReverting        = true;
                    cboTo.SelectedIndex = _lastSelectedToIdx;
                    _isReverting        = false;
                }
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Return any offsets that are not transparent.
        /// </summary>
        /// <param name="feature">The feature to check.</param>
        /// <param name="offsetsToTest">The offsets to check.</param>
        /// <returns>Any offets that are not transparent.</returns>
        private List <Point> GetOffsets(FeatureWrapper featurewrapper, List <Point> offsetsToTest)
        {
            List <Point> nonTransparents = new List <Point>();

            foreach (Point offset in offsetsToTest)
            {
                int   translatedOffsetToTestX = offset.X + featurewrapper.HotspotX;
                int   translatedOffsetToTestY = offset.Y + featurewrapper.HotspotY;
                Point translatedOffsetToTest  = new Point(translatedOffsetToTestX, translatedOffsetToTestY);
                if (Bitmap.OffsetIsInBounds(featurewrapper.Feature.Bitmap, translatedOffsetToTest) &&
                    featurewrapper.Feature.Bitmap[translatedOffsetToTest.Y, translatedOffsetToTest.X] != Features.Feature.TRANSPARENT_VALUE)
                {
                    nonTransparents.Add(offset);
                }
            }

            return(nonTransparents);
        }
Exemplo n.º 23
0
        public MainPage(FeatureWrapper Feat)
            :base(Feat)
        {
            InitializeComponent();

            GroupsCb.Items.Clear();
            GroupsCb.Items.Add("");

            foreach (FeatureWrapper feat in PK.Wrapper.GetFeatures())
            {
                if (!GroupsCb.Items.Contains(feat.Groups))
                {
                    GroupsCb.Items.Add(feat.Groups);
                }
            }
            this.NodeName = Strings.Main;
            HeaderLbl.Text = this.NodeName;
        }
Exemplo n.º 24
0
        public MainPage(FeatureWrapper Feat)
            : base(Feat)
        {
            InitializeComponent();

            GroupsCb.Items.Clear();
            GroupsCb.Items.Add("");

            foreach (FeatureWrapper feat in PK.Wrapper.GetFeatures())
            {
                if (!GroupsCb.Items.Contains(feat.Groups))
                {
                    GroupsCb.Items.Add(feat.Groups);
                }
            }
            this.NodeName  = Strings.Main;
            HeaderLbl.Text = this.NodeName;
        }
Exemplo n.º 25
0
        public FeatureWrapper GetFeature(long index)
        {
            try
            {
                var feature = _ogrLayer.GetFeature(index);
                if (feature == null)
                {
                    return(null);
                }

                var featureWrapper = new FeatureWrapper(feature);
                return(featureWrapper);
            }
            catch (Exception e)
            {
                return(null);
            }
        }
        private void CreateFeatureWrapper(LayerWrapper layer, IDictionary <string, string> propNameToFieldName, BaseFeature data)
        {
            FeatureWrapper feature = layer.CreateFeature();

            feature.Set(propNameToFieldName[nameof(data.SampleId)], data.SampleId);
            feature.Set(propNameToFieldName[nameof(data.ValidityTime)], data.ValidityTime.Value);
            feature.Set(propNameToFieldName[nameof(data.ExtendedData)], data.ExtendedData);
            feature.Set(propNameToFieldName[nameof(data.UserConf)], data.UserConf);
            feature.Set(propNameToFieldName[nameof(data.LandCover)], data.LandCover);
            feature.Set(propNameToFieldName[nameof(data.CropType1)], data.CropType1);
            feature.Set(propNameToFieldName[nameof(data.CropType2)], data.CropType2);
            feature.Set(propNameToFieldName[nameof(data.Irrigation1)], data.Irrigation1);
            feature.Set(propNameToFieldName[nameof(data.Irrigation2)], data.Irrigation2);
            feature.Set(propNameToFieldName[nameof(data.Irrigation3)], data.Irrigation3);

            SetTypeSpecificData(feature, propNameToFieldName, data);

            layer.AddFeatureToLayer(feature);
        }
        /// <summary>
        /// Saves any changes to the grid
        /// </summary>
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                FeatureWrapper from = cboFrom.SelectedItem as FeatureWrapper;
                FeatureWrapper to   = cboTo.SelectedItem as FeatureWrapper;

                if (from != null && to != null)
                {
                    SaveChanges(from, to);
                    UpdateAvailableRanges();
                }
            }
            catch (Exception ex)
            {
                _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "General error.", ex.ToString());
                MessageBox.Show("Error: " + ex.ToString());
            }
        }
Exemplo n.º 28
0
 public MFFeatureTreeNode(FeatureWrapper feature, ref SortedDictionary <string, TreeNode> GroupsDict, ref SortedList <string, TreeNode> VoidGroupsList)
     : this(feature)
 {
     if (!string.IsNullOrEmpty(feature.Groups))
     {
         if (!GroupsDict.ContainsKey(this.Feat.Groups))
         {
             MFTreeNodeBase GroupNode = new MFDirectoryTreeNode(this.Feat.Groups);//this.NewNode(this.Feat.Groups, MFTreeNodeBase.TreeNodeType.Directory, MFTreeNodeBase.ImageKeysEnum.CollapsedDirectory);
             GroupNode.Nodes.Add(this);
             GroupsDict.Add(this.Feat.Groups, GroupNode);
         }
         else
         {
             GroupsDict[this.Feat.Groups].Nodes.Add(this);
         }
     }
     else
     {
         VoidGroupsList.Add(this.Text, this);
     }
 }
Exemplo n.º 29
0
 public MFFeatureTreeNode(FeatureWrapper feature, ref SortedDictionary<string, TreeNode> GroupsDict, ref SortedList<string, TreeNode> VoidGroupsList)
     : this(feature)
 {
     if (!string.IsNullOrEmpty(feature.Groups))
     {
         if (!GroupsDict.ContainsKey(this.Feat.Groups))
         {
             MFTreeNodeBase GroupNode = new MFDirectoryTreeNode(this.Feat.Groups);//this.NewNode(this.Feat.Groups, MFTreeNodeBase.TreeNodeType.Directory, MFTreeNodeBase.ImageKeysEnum.CollapsedDirectory);
             GroupNode.Nodes.Add(this);
             GroupsDict.Add(this.Feat.Groups, GroupNode);
         }
         else
         {
             GroupsDict[this.Feat.Groups].Nodes.Add(this);
         }
     }
     else
     {
         VoidGroupsList.Add(this.Text, this);
     }
 }
Exemplo n.º 30
0
        private void UpdateForm(FeatureWrapper Feat)
        {
            FormText = Strings.Feature + " : " + Feat.Name;
            ModifiedFormText = FormText + "*";

            this.Feat = Feat;
            if (Feat.Filter == null) Feat.Filter = "";

            this.Pages.Clear();

            this.Pages.Add(new Editors.Pages.Feature.MainPage(Feat));
            this.Pages.Add(new Editors.Pages.DescriptionPage(Feat));
            this.Pages.Add(new Editors.Pages.DocumentationPage(Feat));
            this.Pages.Add(new Editors.Pages.Feature.FilterPage(Feat));
            this.Pages.Add(new Editors.Pages.Feature.FlagsPage(Feat));
            this.Pages.Add(new Editors.Pages.Feature.ComponentDependenciesPage(Feat));
            this.Pages.Add(new Editors.Pages.Feature.FeatureDependenciesPage(Feat));


           this.Initialize();

            SetModified(false);
        }
Exemplo n.º 31
0
 public void AddFeatureToLayer(FeatureWrapper feature)
 {
     _ogrLayer.CreateFeature(feature.Value);
 }
Exemplo n.º 32
0
        /// <summary>
        /// Constructs a leaf node from the given parameters.
        /// A reference to the features list is kept, so do not
        /// modify the list after constructing this node.
        /// </summary>
        /// <param name="features">The features at this node.</param>
        /// <param name="offsetsToTest">Any remaining offests to test before returning matches.</param>
        public LeafFeatureTreeNode(FeatureWrapper feature, List <Point> offsetsToTest)
        {
            FeatureWithHotspot = feature;

            OffsetsToTest = GetOffsets(feature, offsetsToTest);
        }
Exemplo n.º 33
0
        public FeaturePageBase(FeatureWrapper Feat)
        {
            InitializeComponent();

            this.Feat = Feat;
        }
Exemplo n.º 34
0
 private void ShowDescription(FeatureWrapper feature)
 {
     DescriptionTB.Clear();
     DescriptionTB.AppendText("Name: " + feature.Name + "\r\n\r\n");
     DescriptionTB.AppendText("Project Path:\r\n");
     DescriptionTB.AppendText(feature.ProjectPath + "\r\n\r\n");
     DescriptionTB.AppendText("Required: " + feature.Required + "\r\n\r\n");
     DescriptionTB.AppendText("Solution Wizard Visible: " + feature.IsSolutionWizardVisible + "\r\n\r\n");
     if (!string.IsNullOrEmpty(feature.Filter))
         DescriptionTB.AppendText("Filter: " + feature.Filter + "\r\n\r\n");
     DescriptionTB.AppendText("Description:\r\n");
     DescriptionTB.AppendText(feature.Description + "\r\n\r\n");
 }
Exemplo n.º 35
0
        private void CheckComponent(ComponentWrapper OwnerComponent, string text, ComponentWrapper component)
        {
            ComponentMessageObject CMO = new ComponentMessageObject();

            CMO.Component = OwnerComponent;

            ComponentsChecked++;
            switch (component.ComponentType)
            {
                #region Library
            case ComponentTypeWrapper.Library:
                if (!CheckComponentGUID(component, text, CMO))
                {
                    return;
                }

                LibraryWrapper LW = PK.Wrapper.FindLibrary(component.Guid);
                if (LW == null)
                {
                    CanTFindComponentsReference(component, text, CMO);
                    return;
                }
                CompareComponentName(component, LW.Name, text, CMO);
                CompareComponentProjectPath(component, LW.ProjectPath, text, CMO);
                break;

                #endregion
                #region Feature
            case ComponentTypeWrapper.Feature:
                if (!CheckComponentGUID(component, text, CMO))
                {
                    return;
                }

                FeatureWrapper FW = PK.Wrapper.FindFeature(component.Guid);
                if (FW == null)
                {
                    CanTFindComponentsReference(component, text, CMO);
                    return;
                }
                CompareComponentName(component, FW.Name, text, CMO);
                CompareComponentProjectPath(component, FW.ProjectPath, text, CMO);
                break;

                #endregion
                #region Assembly
            case ComponentTypeWrapper.MFAssembly:
                if (!CheckComponentGUID(component, text, CMO))
                {
                    return;
                }

                AssemblyWrapper AW = PK.Wrapper.FindAssembly(component.Guid);
                if (AW == null)
                {
                    CanTFindComponentsReference(component, text, CMO);
                    return;
                }
                CompareComponentName(component, AW.Name, text, CMO);
                CompareComponentProjectPath(component, AW.ProjectPath, text, CMO);
                break;

                #endregion
            case ComponentTypeWrapper.MFSolution:
                break;

                #region Processors
            case ComponentTypeWrapper.Processor:
                if (!CheckComponentGUID(component, text, CMO))
                {
                    return;
                }

                ProcessorWrapper PW = PK.Wrapper.FindProcessor(component.Guid);
                if (PW == null)
                {
                    CanTFindComponentsReference(component, text, CMO);
                    return;
                }
                CompareComponentName(component, PW.Name, text, CMO);
                CompareComponentProjectPath(component, PW.ProjectPath, text, CMO);
                break;

                #endregion
            case ComponentTypeWrapper.OperatingSystem:
                break;

            case ComponentTypeWrapper.BuildTool:
                break;

                #region ISA
            case ComponentTypeWrapper.ISA:
                if (!CheckComponentGUID(component, text, CMO))
                {
                    return;
                }

                ISAWrapper IW = PK.Wrapper.FindISA(component.Guid);
                if (IW == null)
                {
                    CanTFindComponentsReference(component, text, CMO);
                    return;
                }
                CompareComponentName(component, IW.Name, text, CMO);
                break;

                #endregion
            case ComponentTypeWrapper.BuildParameter:
                break;

                #region LibraryCategory
            case ComponentTypeWrapper.LibraryCategory:
                if (!CheckComponentGUID(component, text, CMO))
                {
                    return;
                }

                LibraryCategoryWrapper LCW = PK.Wrapper.FindLibraryCategory(component.Guid);
                if (LCW == null)
                {
                    CanTFindComponentsReference(component, text, CMO);
                    return;
                }

                CompareComponentName(component, LCW.Name, text, CMO);

                CompareComponentProjectPath(component, LCW.ProjectPath, text, CMO);
                break;

                #endregion
                #region Unknown
            case ComponentTypeWrapper.Unknown:
                WEMessage UMessage = new WEMessage();
                UMessage.Message       = text + "Component with \"Type\": " + GetStringByComponentType(component.ComponentType);
                UMessage.MessageObject = CMO;
                this.OnWarning(UMessage);
                break;

                #endregion
            default:
                break;
            }
        }
Exemplo n.º 36
0
        public FeaturePageBase(FeatureWrapper Feat)
        {
            InitializeComponent();

            this.Feat = Feat;
        }
Exemplo n.º 37
0
        private void CheckFeature(SearchResultsHolder.SearchComponentDescriptor ProjectDesc, FeatureWrapper feat, string what, bool MatchCase, bool MatchWholeWord)
        {
            SearchResultsHolder.SearchComponentDescriptor CompDesc = new SearchResultsHolder.SearchComponentDescriptor(ComponentWrapper.GetComponentWrapper(feat));
            if (ProjectDesc != null)
                CompDesc.Parent = ProjectDesc;

            m_SearchResults.TotalComponentsSearched++;

            if (MatchWholeWord)
            {
                if (MatchCase)
                {
                    if (feat.Name == what)
                    {
                        m_SearchResults.FindedComponents.Add(CompDesc);
                        OnElementFinded(CompDesc);
                    }
                }
                else
                {
                    if (feat.Name.ToLower() == what.ToLower())
                    {
                        m_SearchResults.FindedComponents.Add(CompDesc);
                        OnElementFinded(CompDesc);
                    }
                }
            }
            else
            {
                if (MatchCase)
                {
                    if (feat.Name.Contains(what))
                    {
                        m_SearchResults.FindedComponents.Add(CompDesc);
                        OnElementFinded(CompDesc);
                    }
                }
                else
                {
                    if (feat.Name.ToLower().Contains(what.ToLower()))
                    {
                        m_SearchResults.FindedComponents.Add(CompDesc);
                        OnElementFinded(CompDesc);
                    }
                }
            }
        }
 internal abstract void SetTypeSpecificData(FeatureWrapper feature, IDictionary <string, string> propNameToFieldName,
                                            BaseFeature baseFeature);
 public ComponentDependenciesPage(FeatureWrapper Wrapper)
     : base(Wrapper, Strings.ComponentDependencies)
 {
     InitializeComponent();
 }
        /// <summary>
        /// A "from" item has been selected; load "to" choices
        /// </summary>
        private void cboFrom_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!_isReverting)
            {
                bool isChangeAccepted = !btnSave.Enabled; // If the save button is disabled, there is no reason to cancel the change

                if (!isChangeAccepted)
                {
                    // Get the current to feature and the from feature that was selected before the index changed, so we can
                    // prompt for unsaved edits
                    FeatureWrapper to            = cboTo.SelectedItem as FeatureWrapper;
                    FeatureWrapper preChangeFrom = null;
                    if (-1 < _lastSelectedFromIdx &&
                        _lastSelectedFromIdx < cboFrom.Items.Count)
                    {
                        preChangeFrom = cboFrom.Items[_lastSelectedFromIdx] as FeatureWrapper;
                    }

                    isChangeAccepted = IsUserSure(preChangeFrom, to);
                }

                if (isChangeAccepted)
                {
                    // The current index is committed
                    _lastSelectedFromIdx = cboFrom.SelectedIndex;

                    // Unload anything that is dependent on the selection of the From Feature
                    ClearGrid();
                    cboTo.Items.Clear();
                    lblAvailableFrom.Text = "";
                    lblAvailableTo.Text   = "";

                    if (null != cboFrom.SelectedItem)
                    {
                        FiberCableWrapper cableWrapper  = cboFrom.SelectedItem as FiberCableWrapper;
                        DeviceWrapper     deviceWrapper = cboFrom.SelectedItem as DeviceWrapper;

                        if (null != cableWrapper)
                        {
                            List <ConnectableDeviceWrapper> devices = _connectionHelper.GetCoincidentDevices(cableWrapper);

                            for (int i = 0; i < devices.Count; i++)
                            {
                                cboTo.Items.Add(devices[i]);
                            }
                        }
                        else if (null != deviceWrapper)
                        {
                            List <ConnectableCableWrapper> cables = _connectionHelper.GetCoincidentCables(deviceWrapper);

                            for (int i = 0; i < cables.Count; i++)
                            {
                                cboTo.Items.Add(cables[i]);
                            }
                        }

                        // Preselect the first item
                        if (0 < cboTo.Items.Count)
                        {
                            cboTo.SelectedItem = cboTo.Items[0];
                        }
                    }
                }
                else
                {
                    // Cancel the change by re-selecting the previous from feature
                    _isReverting          = true;
                    cboFrom.SelectedIndex = _lastSelectedFromIdx;
                    _isReverting          = false;
                }
            }
        }
Exemplo n.º 41
0
 public FeatureDependenciesPage(FeatureWrapper Wrapper)
     : base(Wrapper, Strings.FeatureDependencies)
 {
     InitializeComponent();
 }
Exemplo n.º 42
0
 private void CheckFeature(FeatureWrapper feat, string what, bool MatchCase, bool MatchWholeWord)
 {
     CheckFeature(null, feat, what, MatchCase, MatchWholeWord);
 }
Exemplo n.º 43
0
 /// <summary>
 /// Sets Feature for edition
 /// </summary>
 /// <param name="LibCat"></param>
 public void SetFeat(FeatureWrapper Feat)
 {
     UpdateForm(Feat);
 }
        /// <summary>
        /// Check changes to the grid and save them to the database
        /// </summary>
        /// <param name="from">From feature</param>
        /// <param name="to">To feature</param>
        /// <returns>Success</returns>
        private bool SaveChanges(FeatureWrapper from, FeatureWrapper to)
        {
            bool   result        = false;
            string isNotOkString = string.Empty;

            Dictionary <int, int> currentGrid = new Dictionary <int, int>();
            FiberCableWrapper     cable       = null;
            DeviceWrapper         device      = null;
            bool     isFromEnd = false;
            PortType portType  = PortType.Input;

            #region Detect Direction
            try
            {
                if (from is FiberCableWrapper && to is ConnectableDeviceWrapper)
                {
                    cable     = cboFrom.SelectedItem as FiberCableWrapper;
                    device    = cboTo.SelectedItem as DeviceWrapper;
                    isFromEnd = ((ConnectableDeviceWrapper)device).IsCableFromEnd;
                    portType  = PortType.Input;
                }
                else if (from is DeviceWrapper && to is ConnectableCableWrapper)
                {
                    device    = cboFrom.SelectedItem as DeviceWrapper;
                    cable     = cboTo.SelectedItem as FiberCableWrapper;
                    isFromEnd = ((ConnectableCableWrapper)cable).IsThisFromEnd;
                    portType  = PortType.Output;
                }
                else
                {
                    isNotOkString = "Must connect a cable to a device, or device to a cable.";
                }
            }
            catch (Exception ex)
            {
                isNotOkString = ex.Message;
            }
            #endregion

            try
            {
                if (null != cable && null != device)
                {
                    // Only continue if we have a valid setup
                    try
                    {
                        int aIdx = colFromRange.Index;
                        int bIdx = colToRange.Index;

                        // Less than count-1 lets us avoid the insert row
                        for (int i = 0; i < grdConnections.Rows.Count - 1; i++)
                        {
                            object       aRanges    = (grdConnections[aIdx, i].Value != null ? grdConnections[aIdx, i].Value : "");
                            object       bRanges    = (grdConnections[bIdx, i].Value != null ? grdConnections[bIdx, i].Value : "");
                            List <Range> fromRanges = SpliceAndConnectionUtils.ParseRanges(aRanges.ToString());
                            List <Range> toRanges   = SpliceAndConnectionUtils.ParseRanges(bRanges.ToString());

                            // Check that counts match up
                            if (!SpliceAndConnectionUtils.AreCountsEqual(fromRanges, toRanges))
                            {
                                isNotOkString = "Number of units from A to B must match on each row.";
                            }

                            // Check the ranges are within the feature's units
                            if (PortType.Input == portType)
                            {
                                if (!SpliceAndConnectionUtils.AreRangesWithinFiberCount(fromRanges, cable))
                                {
                                    isNotOkString = "Selected units exceed fiber count for cable.";
                                }
                                else if (!SpliceAndConnectionUtils.AreRangesWithinPortCount(toRanges, device, portType))
                                {
                                    isNotOkString = "Selected units exceed input port count for device.";
                                }
                            }
                            else
                            {
                                if (!SpliceAndConnectionUtils.AreRangesWithinFiberCount(toRanges, cable))
                                {
                                    isNotOkString = "Selected units exceed fiber count for cable.";
                                }
                                else if (!SpliceAndConnectionUtils.AreRangesWithinPortCount(fromRanges, device, portType))
                                {
                                    isNotOkString = "Selected units exceed output port count for device.";
                                }
                            }

                            if (0 < isNotOkString.Length)
                            {
                                // No need to check the rest if this one was not OK
                                break;
                            }

                            List <Connection> matchedUp = SpliceAndConnectionUtils.MatchUp(fromRanges, toRanges);
                            foreach (Connection connection in matchedUp)
                            {
                                Range a        = connection.ARange;
                                Range b        = connection.BRange;
                                int   numUnits = a.High - a.Low + 1;
                                for (int offset = 0; offset < numUnits; offset++)
                                {
                                    int aUnit = a.Low + offset;
                                    int bUnit = b.Low + offset;

                                    if (currentGrid.ContainsKey(aUnit) ||
                                        currentGrid.ContainsValue(bUnit))
                                    {
                                        isNotOkString = string.Format("Duplicate connection found from {0} to {1}.", aUnit, bUnit);
                                        // No need to check the rest if this one was not OK
                                        break;
                                    }
                                    else
                                    {
                                        currentGrid[aUnit] = bUnit;
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        isNotOkString = ex.Message;
                        MessageBox.Show(ex.Message);
                    }

                    // Check the ranges are within the feature's units
                    List <int> checkToUnits   = new List <int>();
                    List <int> checkFromUnits = new List <int>();

                    // Anything that is in the current grid, we will see if it is available. But if it was deleted, we can ignore
                    // checking its availabilty, because we are about to free it up. Also if it was original, we can ignore it,
                    // since we are reprocessing it. Duplicates ON the grid have already been checked for.
                    // NOTE: We can simplify this to just check original, since any deleted ones were in the original.
                    foreach (int toUnit in currentGrid.Values)
                    {
                        if (!_original.ContainsValue(toUnit))
                        {
                            checkToUnits.Add(toUnit);
                        }
                    }

                    foreach (int fromUnit in currentGrid.Keys)
                    {
                        if (!_original.ContainsKey(fromUnit))
                        {
                            checkFromUnits.Add(fromUnit);
                        }
                    }

                    if (PortType.Input == portType)
                    {
                        if (!SpliceAndConnectionUtils.AreRangesAvailable(checkToUnits, device, portType))
                        {
                            isNotOkString = "Some To units are not in the available ranges for the device.";
                        }
                        else if (!SpliceAndConnectionUtils.AreRangesAvailable(checkFromUnits, cable, isFromEnd))
                        {
                            isNotOkString = "Some From units are not in the available ranges for the cable.";
                        }
                    }
                    else
                    {
                        if (!SpliceAndConnectionUtils.AreRangesAvailable(checkFromUnits, device, portType))
                        {
                            isNotOkString = "Some From units are not in the available ranges for the device.";
                        }
                        else if (!SpliceAndConnectionUtils.AreRangesAvailable(checkToUnits, cable, isFromEnd))
                        {
                            isNotOkString = "Some To units are not in the available ranges for the cable.";
                        }
                    }

                    if (0 == isNotOkString.Length)
                    {
                        // For the deleted ones, if they were added back, don't delete them...
                        List <int> keys = new List <int>();
                        keys.AddRange(_deleted.Keys);
                        foreach (int key in keys)
                        {
                            if (currentGrid.ContainsKey(key) &&
                                currentGrid[key] == _deleted[key])
                            {
                                // It is added back, so don't delete it
                                _deleted.Remove(key);
                            }
                        }

                        _connectionHelper.BreakConnections(cable, device, _deleted, portType, false);

                        // For the added ones, if they already exist or are not available, don't add them
                        // Since we already know they are in the fiber count range, the only problem would be if they were already
                        // spliced. This would be the case if (1) it was part of the original, (2) has already appeared higher
                        // on the currentGrid, (3) is spliced to something else. (2) is handled when building currentGrid, by checking
                        // if the aUnit or bUnit was already used and (3) is checked in the AreRangesAvailable checks. So now we will
                        // confirm (1)...
                        keys.Clear();
                        keys.AddRange(currentGrid.Keys);
                        foreach (int key in keys)
                        {
                            if (_original.ContainsKey(key) &&
                                _original[key] == currentGrid[key])
                            {
                                currentGrid.Remove(key);
                            }
                        }

                        _connectionHelper.MakeConnections(cable, device, currentGrid, isFromEnd, portType, false);

                        // These are no longer part of the originals
                        foreach (int deletedKey in _deleted.Keys)
                        {
                            _original.Remove(deletedKey);
                        }

                        // These are now part of the originals
                        foreach (KeyValuePair <int, int> addedPair in currentGrid)
                        {
                            _original[addedPair.Key] = addedPair.Value;
                        }

                        _deleted.Clear(); // The grid is fresh

                        // Set the existing rows as committed data. Less than count-1 lets us avoid the insert row
                        for (int i = 0; i < grdConnections.Rows.Count - 1; i++)
                        {
                            grdConnections.Rows[i].ReadOnly = true;
                        }

                        btnSave.Enabled = false;
                        btnSave.Tag     = false; // No edits have been made
                        result          = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.ToString());
            }

            if (0 < isNotOkString.Length)
            {
                string message = string.Format("{0}\nPlease correct this and try again.", isNotOkString);
                MessageBox.Show(message, "Connection Editor", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(result);
        }