Esempio n. 1
0
        public void When_Element_Count_is_equal_Then_DisplayMode_is_equal()
        {
            // Act
            var displayMode1 = new DisplayMode(8);
            var displayMode2 = new DisplayMode(8);

            // Assert
            Assert.IsTrue(displayMode1.Equals(displayMode2));
        }
    public void OnModeToggle()
    {
        if (actualMode.Equals(DisplayMode.ENERGY))
        {
            energyBar.SetActive(false);
            for (int y = 0; y < heightTotal; y++)
            {
                for (int x = 0; x < widthTotal; x++)
                {
                    objects[y, x].GetComponent <Image>().color = actualColor[y, x];
                }
            }

            actualMode = DisplayMode.STRUCTURE;
        }
        else if (actualMode.Equals(DisplayMode.STRUCTURE))
        {
            int tempMaxEnergy = 1;
            energyBar.SetActive(true);
            // Looking for max energy to scale up
            for (int y = 0; y < heightTotal; y++)
            {
                for (int x = 0; x < widthTotal; x++)
                {
                    if (objects[y, x].GetComponent <Grain>().energy > tempMaxEnergy)
                    {
                        tempMaxEnergy = objects[y, x].GetComponent <Grain>().energy;
                    }
                }
            }
            maxValueText.text = tempMaxEnergy.ToString();

            for (int y = 0; y < heightTotal; y++)
            {
                for (int x = 0; x < widthTotal; x++)
                {
                    objects[y, x].GetComponent <Image>().color = ColorHandler.MapEnergyToColor(objects[y, x].GetComponent <Grain>().energy, tempMaxEnergy);
                }
            }
            actualMode = DisplayMode.ENERGY;
        }
    }
 private int GetNumberOfPanes()
 {
     if (DisplayMode.Equals("List"))
     {
         return(PlotItems.Count);
     }
     if (DisplayMode.Equals("GroupOverlay"))
     {
         return(PlotItems.Select(p => p.Group).Distinct().Count());
     }
     return(1);
 }
 private static void ViewFromBehavior(EA.Repository repository, EA.Element el, DisplayMode showBehavior)
 {
     EA.Method method = Util.GetOperationFromBrehavior(repository, el);
     if (method != null)
     {
         if (showBehavior.Equals(DisplayMode.Behavior))
         {
             BehaviorForOperation(repository, method);
         }
         else
         {
             repository.ShowInProjectView(method);
         }
     }
 }
Esempio n. 5
0
 private void HandleModeCommands()
 {
     if (DisplayMode.Equals("Overlay") && OverlayModeCommand.IsChecked)
     {
         ListModeCommand.IsChecked         = false;
         GroupOverlayModeCommand.IsChecked = false;
     }
     else if (DisplayMode.Equals("GroupOverlay") && GroupOverlayModeCommand.IsChecked)
     {
         ListModeCommand.IsChecked    = false;
         OverlayModeCommand.IsChecked = false;
     }
     else
     {
         ListModeCommand.IsChecked         = true;
         OverlayModeCommand.IsChecked      = false;
         GroupOverlayModeCommand.IsChecked = false;
     }
 }
        protected override void OnPreRender(EventArgs e)
        {
            if (DisplayMode.Equals("ENGLISH", StringComparison.InvariantCultureIgnoreCase))
            {
                if (_englishCombo.Items.FindItemByValue(_originalValue) != null)
                {
                    _englishCombo.Items.FindItemByValue(_originalValue).Selected = true;
                }
            }
            else
            {
                if (_nativeCombo.Items.FindItemByValue(_originalValue) != null)
                {
                    _nativeCombo.Items.FindItemByValue(_originalValue).Selected = true;
                }
            }

            _modeRadioButtonList.Items.FindByValue(DisplayMode).Selected = true;

            foreach (RadComboBoxItem item in _englishCombo.Items)
            {
                item.ImageUrl = string.Format(FlagImageUrlFormatString, item.Value);
            }
            foreach (RadComboBoxItem item in _nativeCombo.Items)
            {
                item.ImageUrl = string.Format(FlagImageUrlFormatString, item.Value);
            }

            _englishCombo.AutoPostBack     = AutoPostBack;
            _englishCombo.CausesValidation = CausesValidation;
            _englishCombo.Visible          = (DisplayMode.Equals("ENGLISH", StringComparison.InvariantCultureIgnoreCase));

            _nativeCombo.AutoPostBack     = AutoPostBack;
            _nativeCombo.CausesValidation = CausesValidation;
            _nativeCombo.Visible          = (DisplayMode.Equals("NATIVE", StringComparison.InvariantCultureIgnoreCase));

            _modeRadioButtonList.Visible = ShowModeButtons;

            _englishCombo.Width = Width;
            _nativeCombo.Width  = Width;

            base.OnPreRender(e);
        }
        private void UpdatePlotItems()
        {
            List <string> groups = PlotItems.Select(p => p.Group).Distinct().ToList();

            for (int i = 0; i < PlotItems.Count; i++)
            {
                PlotItem plotItem   = PlotItems[i];
                string   group      = "";
                int      groupIndex = 0;
                if (plotItem.Group != null)
                {
                    group      = plotItem.Group;
                    groupIndex = groups.IndexOf(group);
                }
                plotItem.Legend = null;
                plotItem.Color  = colorArray[i];
                if (ColorBySampleGroupFlag)
                {
                    plotItem.Color = GroupColors[group];
                }

                plotItem.HorizontalPosition = i;
                if (DisplayMode.Equals("Overlay"))
                {
                    plotItem.HorizontalPosition = 0;
                    Color color = plotItem.Color;
                    plotItem.Color = Color.FromArgb(OVERLAY_OPACITY, color.R, color.G, color.B);
                }
                if (DisplayMode.Equals("GroupOverlay"))
                {
                    plotItem.HorizontalPosition = groupIndex;
                    Color color = plotItem.Color;
                    plotItem.Color = Color.FromArgb(OVERLAY_OPACITY, color.R, color.G, color.B);
                    if (ColorBySampleGroupFlag)
                    {
                        plotItem.Legend = group;
                    }
                }
            }
        }
        // display behavior or definition for selected element
        private static void DisplayForSelectedElement(EA.Repository repository, DisplayMode showBehavior)
        {
            EA.ObjectType oType = repository.GetContextItemType();
            // Method found
            if (oType.Equals(EA.ObjectType.otMethod))
            {
                // display behavior for method
                BehaviorForOperation(repository, (EA.Method)repository.GetContextObject());
            }
            if (oType.Equals(EA.ObjectType.otDiagram))
            {
                // find parent element
                EA.Diagram dia = (EA.Diagram)repository.GetContextObject();
                if (dia.ParentID > 0)
                {
                    // find parent element
                    EA.Element parentEl = repository.GetElementByID(dia.ParentID);
                    //
                    ViewFromBehavior(repository, parentEl, showBehavior);
                }
                else
                {
                    // open diagram
                    repository.OpenDiagram(dia.DiagramID);
                }
            }


            // Connector / Message found
            if (oType.Equals(EA.ObjectType.otConnector))
            {
                EA.Connector con = (EA.Connector)repository.GetContextObject();
                if (con.Type.Equals("StateFlow"))
                {
                    EA.Method m = Util.GetOperationFromConnector(repository, con);
                    if (m != null)
                    {
                        if (showBehavior.Equals(DisplayMode.Behavior))
                        {
                            BehaviorForOperation(repository, m);
                        }
                        else
                        {
                            repository.ShowInProjectView(m);
                        }
                    }
                }

                if (con.Type.Equals("Sequence"))
                {
                    // If name is of the form: OperationName(..) the the operation is associated to an method
                    string opName = con.Name;
                    if (opName.EndsWith(")"))
                    {
                        // extract the name
                        int pos = opName.IndexOf("(");
                        opName = opName.Substring(0, pos);
                        EA.Element el = repository.GetElementByID(con.SupplierID);
                        // find operation by name
                        foreach (EA.Method op in el.Methods)
                        {
                            if (op.Name == opName)
                            {
                                BehaviorForOperation(repository, op);
                            }
                        }
                        if ((el.Type.Equals("Sequence") || el.Type.Equals("Object")) && el.ClassfierID > 0)
                        {
                            el = (EA.Element)repository.GetElementByID(el.ClassifierID);
                            foreach (EA.Method op in el.Methods)
                            {
                                if (op.Name == opName)
                                {
                                    if (showBehavior.Equals(DisplayMode.Behavior))
                                    {
                                        BehaviorForOperation(repository, op);
                                    }
                                    else
                                    {
                                        repository.ShowInProjectView(op);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            // Element
            if (oType.Equals(EA.ObjectType.otElement))
            {
                EA.Element el = (EA.Element)repository.GetContextObject();

                if (el.Type.Equals("Activity"))
                {
                    // Open Behavior for Activity
                    Util.OpenBehaviorForElement(repository, el);
                }
                if (el.Type.Equals("Action"))
                {
                    foreach (EA.CustomProperty custproperty in el.CustomProperties)
                    {
                        if (custproperty.Name.Equals("kind") && custproperty.Value.Equals("CallOperation"))
                        {
                            ShowFromElement(repository, el, showBehavior);
                        }
                        if (custproperty.Name.Equals("kind") && custproperty.Value.Equals("CallBehavior"))
                        {
                            el = repository.GetElementByID(el.ClassfierID);
                            Util.OpenBehaviorForElement(repository, el);
                        }
                    }
                }
                if (el.Type.Equals("Activity") || el.Type.Equals("StateMachine") || el.Type.Equals("Interaction"))
                {
                    ViewFromBehavior(repository, el, showBehavior);
                }
            }
        }
        // display behavior or definition for selected element
        // enum displayMode: "Behavior" or "Method"
        public static void DisplayOperationForSelectedElement(Repository repository, DisplayMode showBehavior)
        {
            ObjectType oType = repository.GetContextItemType();
            // Method found
            if (oType.Equals(ObjectType.otMethod))
            {
                // display behavior for method
                Appl.DisplayBehaviorForOperation(repository, (Method) repository.GetContextObject());
            }
            if (oType.Equals(ObjectType.otDiagram))
            {
                // find parent element
                var dia = (Diagram) repository.GetContextObject();
                if (dia.ParentID > 0)
                {
                    // find parent element
                    Element parentEl = repository.GetElementByID(dia.ParentID);
                    //
                    LocateOperationFromBehavior(repository, parentEl, showBehavior);
                }
                else
                {
                    // open diagram
                    repository.OpenDiagram(dia.DiagramID);
                }
            }


            // Connector / Message found
            if (oType.Equals(ObjectType.otConnector))
            {
                var con = (Connector) repository.GetContextObject();
                SelectBehaviorFromConnector(repository, con, showBehavior);
            }

            // Element
            if (oType.Equals(ObjectType.otElement))
            {
                var el = (Element) repository.GetContextObject();
                // locate text or frame
                if (LocateTextOrFrame(repository, el)) return;

                if (el.Type.Equals("Activity") & showBehavior.Equals(DisplayMode.Behavior))
                {
                    // Open Behavior for Activity
                    Util.OpenBehaviorForElement(repository, el);
                }
                if (el.Type.Equals("State"))
                {
                    // get operations
                    foreach (Method m in el.Methods)
                    {
                        // display behaviors for methods
                        Appl.DisplayBehaviorForOperation(repository, m);
                    }
                }

                if (el.Type.Equals("Action"))
                {
                    foreach (CustomProperty custproperty in el.CustomProperties)
                    {
                        if (custproperty.Name.Equals("kind") && custproperty.Value.Equals("CallOperation"))
                        {
                            ShowFromElement(repository, el, showBehavior);
                        }
                        if (custproperty.Name.Equals("kind") && custproperty.Value.Equals("CallBehavior"))
                        {
                            el = repository.GetElementByID(el.ClassfierID);
                            Util.OpenBehaviorForElement(repository, el);
                        }
                    }
                }
                if (showBehavior.Equals(DisplayMode.Method) & (
                    el.Type.Equals("Activity") || el.Type.Equals("StateMachine") || el.Type.Equals("Interaction")))
                {
                    LocateOperationFromBehavior(repository, el, showBehavior);
                }
            }
        }
 static void LocateOperationFromBehavior(Repository repository, Element el, DisplayMode showBehavior)
 {
     Method method = Util.GetOperationFromBrehavior(repository, el);
     if (method != null)
     {
         if (showBehavior.Equals(DisplayMode.Behavior))
         {
             Appl.DisplayBehaviorForOperation(repository, method);
         }
         else
         {
             repository.ShowInProjectView(method);
         }
     }
 }
        /// <summary>
        /// Display behavior or definition for selected connector ("StateFlow","Sequence"). It Displays the operation (displayMode=Method) or the Behavior (displayMode=Behavior).
        /// <para/>- enum displayMode: "Behavior" or "Method"
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="con"></param>
        /// <param name="showBehavior"></param>
        static void SelectBehaviorFromConnector(Repository repository, Connector con, DisplayMode showBehavior)
        {
            if (con.Type.Equals("StateFlow"))
            {
                Method m = Util.GetOperationFromConnector(repository, con);
                if (m != null)
                {
                    if (showBehavior.Equals(DisplayMode.Behavior))
                    {
                        Appl.DisplayBehaviorForOperation(repository, m);
                    }
                    else
                    {
                        repository.ShowInProjectView(m);
                    }
                }
            }

            if (con.Type.Equals("Sequence"))
            {
                // If name is of the form: OperationName(..) the operation is associated to an method
                string opName = con.Name;
                if (opName.EndsWith(")", StringComparison.Ordinal))
                {
                    // extract the name
                    int pos = opName.IndexOf("(", StringComparison.Ordinal);
                    opName = opName.Substring(0, pos);
                    Element el = repository.GetElementByID(con.SupplierID);
                    // find operation by name
                    foreach (Method op in el.Methods)
                    {
                        if (op.Name == opName)
                        {
                            repository.ShowInProjectView(op);
                            //Appl.DisplayBehaviorForOperation(Repository, op);
                            return;
                        }
                    }
                    // If connector 0 Sequence and Classifier exists
                    if (con.Type.Equals("Sequence") && ( el.ClassfierID > 0 || el.PropertyType > 0))
                    {
                        if ("PartPort".Contains(el.Type))
                        {
                            if (el.PropertyType > 0)
                            {
                                el = repository.GetElementByID(el.PropertyType);
                            }
                            else
                            {
                                if (el.ClassifierID > 0)
                                    el = repository.GetElementByID(el.ClassifierID);
                                else return;

                            }
                        }
                        else
                        {
                            if (el.ClassifierID > 0)
                                el = repository.GetElementByID(el.ClassifierID);
                        }

                        foreach (Method op in el.Methods)
                        {
                            if (op.Name == opName)
                            {
                                if (showBehavior.Equals(DisplayMode.Behavior))
                                {
                                    Appl.DisplayBehaviorForOperation(repository, op);
                                }
                                else
                                {
                                    repository.ShowInProjectView(op);
                                }
                            }
                        }
                    }
                }
            }
        }