public static void RemoveElement(BaseElement _element)
 {
     // remove new eleent to lists
     if (ElementsManager.inst.ids.Contains (_element._id)) {
         ElementsManager.inst.ids.Remove (_element._id);
     }
     if (gameElements.ContainsKey(_element._id)){
         gameElements.Remove(_element._id);
     }
     if (ElementsManager.inst.bodyids.Contains(_element._id)){
         ElementsManager.inst.bodyids.Remove(_element._id);
     }
 }
    public void PassElementBetweenTeams(BaseElement _be, int from, int to)
    {
        Debug.Log ("element passes from team "+from.ToString()+" to "+to.ToString());
        //change team ownership
        _be.elProperties [PropertyType.TeamID].val = to;
        //atacker num to default
        _be.elProperties [PropertyType.AttackerNum].val = -1;
        //change sign of V
        _be.elProperties [PropertyType.V].val *= -1;

        teams [from].elements.Remove (_be);
        teams [to].elements.Add (_be);
    }
        public override void ParseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model)
        {
            if (!(parentElement is Event))
            {
                return;
            }

            SignalEventDefinition eventDefinition = new SignalEventDefinition();

            BpmnXMLUtil.AddXMLLocation(eventDefinition, xtr);
            eventDefinition.SignalRef        = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_SIGNAL_REF);
            eventDefinition.SignalExpression = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_SIGNAL_EXPRESSION);
            if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_ACTIVITY_ASYNCHRONOUS)))
            {
                eventDefinition.Async = bool.Parse(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_ACTIVITY_ASYNCHRONOUS));
            }

            BpmnXMLUtil.ParseChildElements(BpmnXMLConstants.ELEMENT_EVENT_SIGNALDEFINITION, eventDefinition, xtr, model);

            ((Event)parentElement).EventDefinitions.Add(eventDefinition);
        }
        public void TestGetItemAsPageSuccess()
        {
            var element     = new BaseElement();
            var propData    = new Mock <IPropertyData>();
            var page        = new Mock <IPage>(MockBehavior.Strict);
            var elementPage = new Mock <IPage>(MockBehavior.Strict);

            var pageBase = new Mock <IPageElementHandler <BaseElement> >(MockBehavior.Strict);

            pageBase.Setup(p => p.GetPageFromElement(element)).Returns(elementPage.Object);

            var propertyData = CreatePropertyData(pageBase, element);

            var result = propertyData.GetItemAsPage();

            Assert.AreSame(elementPage.Object, result);

            pageBase.VerifyAll();
            page.VerifyAll();
            propData.VerifyAll();
        }
        public void TestGetCurrentValueFromElementProperty()
        {
            var element  = new BaseElement();
            var propData = new Mock <IPropertyData>();
            var page     = new Mock <IPage>(MockBehavior.Strict);

            var pageBase = new Mock <IPageElementHandler <BaseElement> >(MockBehavior.Strict);

            pageBase.Setup(p => p.ElementExistsCheck(element)).Returns(true);
            pageBase.Setup(p => p.GetElementText(element)).Returns("My Value");

            var propertyData = CreatePropertyData(pageBase, element);

            var result = propertyData.GetCurrentValue();

            Assert.AreEqual("My Value", result);

            pageBase.VerifyAll();
            page.VerifyAll();
            propData.VerifyAll();
        }
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            if (_lastSelectedElement == null)
            {
                return;
            }

            BaseElement element = _lastSelectedElement.Element;


            DialogResult result = MessageBox.Show("Deletion of a category removes all sub-items. Are you sure?",
                                                  $"Deletion of {element.Name}",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result == DialogResult.Yes)
            {
                _currentCategory.Remove(_lastSelectedElement.Element);
                DisplayCurrentCategory();
                SaveToFile();
            }
        }
        protected internal override bool WriteExtensionChildElements(BaseElement element, bool didWriteExtensionStartElement, XMLStreamWriter xtw)
        {
            ServiceTask serviceTask = (ServiceTask)element;

            if (serviceTask.CustomProperties.Count > 0)
            {
                foreach (CustomProperty customProperty in serviceTask.CustomProperties)
                {
                    if (string.IsNullOrWhiteSpace(customProperty.SimpleValue))
                    {
                        continue;
                    }

                    if (!didWriteExtensionStartElement)
                    {
                        xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EXTENSIONS, BpmnXMLConstants.BPMN2_NAMESPACE);
                        didWriteExtensionStartElement = true;
                    }
                    xtw.WriteStartElement(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.ELEMENT_FIELD, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE);
                    xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_FIELD_NAME, customProperty.Name);
                    if ((customProperty.SimpleValue.Contains("${") || customProperty.SimpleValue.Contains("#{")) && customProperty.SimpleValue.Contains("}"))
                    {
                        xtw.WriteStartElement(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.ATTRIBUTE_FIELD_EXPRESSION, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE);
                    }
                    else
                    {
                        xtw.WriteStartElement(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.ELEMENT_FIELD_STRING, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE);
                    }
                    xtw.WriteCharacters(customProperty.SimpleValue);
                    xtw.WriteEndElement();
                    xtw.WriteEndElement();
                }
            }
            else
            {
                didWriteExtensionStartElement = FieldExtensionExport.WriteFieldExtensions(serviceTask.FieldExtensions, didWriteExtensionStartElement, xtw);
            }

            return(didWriteExtensionStartElement);
        }
Beispiel #8
0
        public static Size GetTextSize(BaseElement element)
        {
            var sizeTmp      = Size.Empty;
            var direction    = element is BaseLinkElement ? LabelEditDirection.Both : LabelEditDirection.UpDown;
            var labelElement = ((ILabelElement)element).Label;

            switch (direction)
            {
            case LabelEditDirection.UpDown:
                sizeTmp = DiagramHelper.MeasureString(labelElement.Text, labelElement.Font, labelElement.Size.Width,
                                                      labelElement.Format);
                break;

            case LabelEditDirection.Both:
                sizeTmp = DiagramHelper.MeasureString(labelElement.Text, labelElement.Font);
                break;
            }

            sizeTmp.Height += 30;

            return(sizeTmp);
        }
        protected internal override bool WriteExtensionChildElements(BaseElement element, bool didWriteExtensionStartElement, XMLStreamWriter xtw)
        {
            ValuedDataObject dataObject = (ValuedDataObject)element;

            if (!string.IsNullOrWhiteSpace(dataObject.Id) && dataObject.Value != null)
            {
                if (!didWriteExtensionStartElement)
                {
                    xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EXTENSIONS, BpmnXMLConstants.BPMN2_NAMESPACE);
                    didWriteExtensionStartElement = true;
                }

                xtw.WriteStartElement(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.ELEMENT_DATA_VALUE, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE);
                if (dataObject.Value != null)
                {
                    string value;
                    if (dataObject is DateDataObject)
                    {
                        value = ((DateTime)dataObject.Value).ToString(sdf);
                    }
                    else
                    {
                        value = dataObject.Value.ToString();
                    }

                    if (dataObject is StringDataObject && xmlChars.IsMatch(value))
                    {
                        xtw.WriteCData(value);
                    }
                    else
                    {
                        xtw.WriteCharacters(value);
                    }
                }
                xtw.WriteEndElement();
            }

            return(didWriteExtensionStartElement);
        }
Beispiel #10
0
        private void ElementClick(object sender, EventArgs e)
        {
            BubblingEventArgs barg = HTMLUIControl.GetBublingEventArgs(e);
            BaseElement       elem = barg.RootSender as BaseElement;

            if (elem.Name == "p" && formatOrange != null)
            {
                if (radioButton1.Checked == true)
                {
                    elem.Format = formatOrange;
                }
                if (radioButton2.Checked == true)
                {
                    elem.Format = formatGreen;
                }
                else if (radioButton1.Checked == false && radioButton2.Checked == false)
                {
                    MessageBox.Show("Check any of the test Boxes to show the Format");
                }
                this.label1.Text = elem.Format.Name.ToString() + ":\n" + elem.Format.Font.ToString() + elem.Format.BackgroundColor.ToString();
            }
        }
Beispiel #11
0
        public static bool CastRay(Vector2 start, Vector2 direction, out RaycastInfo info, float maxDistance = 1000f)
        {
            Line line = new Line(start, start + direction * maxDistance);

            List <(Line line, Vector2 point, BaseElement element)> hits = new List <(Line, Vector2, BaseElement)>();

            for (int i = 0; i < GameLayer.Instance.Elements.Count; i++)
            {
                BaseElement element  = GameLayer.Instance.Elements[i];
                var         collider = element.rotatedCollider.lines;
                foreach (Line line1 in collider)
                {
                    if (Collision.LineLine(line, line1, out Vector2 intersection))
                    {
                        hits.Add((line1, intersection, element));
                    }
                }
            }

            if (hits.Count > 0)
            {
                (Line line1, Vector2 point, BaseElement element) = hits.OrderBy(x => Vector2.DistanceSquared(x.Item2, start)).First();

                var   dir = Vector2.Normalize(line1.end - line1.start);
                float dot = Vector2.Dot(direction, dir.PerpendicularLeft);

                info = new RaycastInfo
                {
                    point   = point,
                    normal  = dot < 0 ? dir.PerpendicularLeft : dir.PerpendicularRight,
                    element = element
                };

                return(true);
            }

            info = new RaycastInfo();
            return(false);
        }
Beispiel #12
0
        public void OpenUI(BaseBag bag)
        {
            Type bagType = UICache.ContainsKey(bag.GetType()) ? bag.GetType() : bag.GetType().BaseType;

            bag.UI    = (IBagPanel)Activator.CreateInstance(UICache[bagType]);
            bag.UI.ID = bag.ID;

            BaseElement element = (BaseElement)bag.UI;

            element.Activate();

            if (Main.LocalPlayer.GetModPlayer <PSPlayer>().UIPositions.TryGetValue(bag.ID, out Vector2 position))
            {
                element.HAlign   = element.VAlign = 0;
                element.Position = position;
            }

            Append(element);
            ContainerLibrary.ContainerLibrary.ItemHandlerUI.Add((IItemHandlerUI)element);

            Main.PlaySound(bag.OpenSound);
        }
Beispiel #13
0
        public void TestValidateListRowCountGreaterThanEqualsSuccess()
        {
            var element     = new BaseElement();
            var listElement = new BaseElement();
            var propData    = new Mock <IPropertyData>();
            var page        = new Mock <IPage>(MockBehavior.Strict);

            var pageBase = new Mock <IPageElementHandler <BaseElement> >(MockBehavior.Strict);

            var propertyData = CreatePropertyData(pageBase, element, (p, f) => f(new List <BaseElement> {
                listElement
            }));

            var result = propertyData.ValidateListRowCount(NumericComparisonType.GreaterThanEquals, 1);

            Assert.AreEqual(true, result.Item1);
            Assert.AreEqual(1, result.Item2);

            pageBase.VerifyAll();
            page.VerifyAll();
            propData.VerifyAll();
        }
Beispiel #14
0
        public static void SetTextBoxLocation(BaseElement el, TextBox tb)
        {
            if (!(el is ILabelElement))
            {
                return;
            }

            var lab = ((ILabelElement)el).Label;

            el.Invalidate();
            lab.Invalidate();

            if (lab.Text.Length > 0)
            {
                tb.Location = lab.Location;
                tb.Size     = lab.Size;
            }
            else
            {
                const string tmpText = "XXXXXXX";
                var          sizeTmp = DiagramUtil.MeasureString(tmpText, lab.Font, lab.Size.Width, lab.Format);

                if (el is BaseLinkElement)
                {
                    tb.Size     = sizeTmp;
                    tb.Location = new Point(el.Location.X + (el.Size.Width / 2) - (sizeTmp.Width / 2),
                                            el.Location.Y + (el.Size.Height / 2) - (sizeTmp.Height / 2));
                }
                else
                {
                    sizeTmp.Width = el.Size.Width;
                    tb.Size       = sizeTmp;
                    tb.Location   = new Point(el.Location.X,
                                              el.Location.Y + (el.Size.Height / 2) - (sizeTmp.Height / 2));
                }
            }

            SetTextBoxBorder(tb);
        }
Beispiel #15
0
        public void TestValidateListContains()
        {
            var element     = new BaseElement();
            var listElement = new BaseElement();
            var validation  = ItemValidationHelper.Create("MyProperty", "My Data");
            var validations = new List <ItemValidation> {
                validation
            };

            var    propData = new Mock <IPropertyData>();
            string actualValue;

            propData.Setup(p => p.ValidateItem(validation, out actualValue)).Returns(true);

            var page = new Mock <IPage>(MockBehavior.Strict);

            // ReSharper disable once RedundantAssignment
            var property = propData.Object;

            page.Setup(p => p.TryGetProperty("MyProperty", out property)).Returns(true);

            var pageBase = new Mock <IPageElementHandler <BaseElement> >(MockBehavior.Strict);

            pageBase.Setup(p => p.GetPageFromElement(listElement)).Returns(page.Object);

            var propertyData = CreatePropertyData(pageBase, element, (p, f) => f(new List <BaseElement> {
                listElement
            }));

            var result = propertyData.ValidateList(ComparisonType.Contains, validations);

            Assert.IsTrue(result.IsValid);
            Assert.AreEqual(1, result.ItemCount);

            pageBase.VerifyAll();
            page.VerifyAll();
            propData.VerifyAll();
        }
        private static void ItemSlot_OverrideHover(ILContext il)
        {
            ILCursor cursor    = new ILCursor(il);
            ILLabel  label     = cursor.DefineLabel();
            ILLabel  caseStart = cursor.DefineLabel();

            ILLabel[] targets = null;
            if (cursor.TryGotoNext(i => i.MatchSwitch(out targets)))
            {
                targets[0] = caseStart;
            }

            if (cursor.TryGotoNext(i => i.MatchLdsfld(typeof(Main).GetField("npcShop", Utility.defaultFlags))))
            {
                cursor.MarkLabel(caseStart);

                cursor.Emit(OpCodes.Ldloc, 0);
                cursor.EmitDelegate <Func <Item, bool> >(item =>
                {
                    BaseElement BaseElement = PanelUI.Instance.Children.FirstOrDefault(element => (element as IItemHandlerUI)?.Handler?.HasSpace(item) ?? false);
                    string texture          = (BaseElement as IItemHandlerUI)?.GetTexture(item);

                    if (!string.IsNullOrWhiteSpace(texture))
                    {
                        BaseLibrary.Hooking.SetCursor(texture);
                        return(true);
                    }

                    return(false);
                });
                cursor.Emit(OpCodes.Brtrue, label);
            }

            if (cursor.TryGotoNext(i => i.MatchLdsflda(typeof(Main).GetField("keyState", Utility.defaultFlags))))
            {
                cursor.MarkLabel(label);
            }
        }
        internal void CalcWindowSize(BaseElement element)
        {
            if (!_enabledCalc)
            {
                return;
            }

            var elementLocation = element.Location;
            var elementSize     = element.Size;

            var val = elementLocation.X + elementSize.Width - _location.X;

            if (val > _size.Width)
            {
                _size.Width = val;
            }

            val = elementLocation.Y + elementSize.Height - _location.Y;
            if (val > _size.Height)
            {
                _size.Height = val;
            }
        }
        public static void SelectFile(this IWebDriver driver, BaseElement baseElement, string fileFullPath)
        {
            try
            {
                fileFullPath = Path.GetFullPath((new Uri(fileFullPath)).LocalPath);
                Log.Information("SelectFile()...{element}, {file}", baseElement, fileFullPath);

                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(ConfigManager.MaxTimeout));
                wait.Until(c => c.FindElement(baseElement.ToBy()));
                IWebElement element = driver.FindElement(baseElement.ToBy());
                element.Click();
                Thread.Sleep(7000);
                System.Windows.Forms.SendKeys.SendWait(fileFullPath);
                Thread.Sleep(3000);
                System.Windows.Forms.SendKeys.SendWait(@"{Enter}");
            }
            catch (Exception ex)
            {
                Log.Error("SelectFile()...{element}, {file}, {message}, {trace}",
                          baseElement, fileFullPath, ex.Message, ex.StackTrace);
                throw ex;
            }
        }
Beispiel #19
0
            public override void ParseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model)
            {
                string source           = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_IOPARAMETER_SOURCE);
                string sourceExpression = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_IOPARAMETER_SOURCE_EXPRESSION);
                string target           = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_IOPARAMETER_TARGET);

                if ((!string.IsNullOrWhiteSpace(source) || !string.IsNullOrWhiteSpace(sourceExpression)) && !string.IsNullOrWhiteSpace(target))
                {
                    IOParameter parameter = new IOParameter();
                    if (!string.IsNullOrWhiteSpace(sourceExpression))
                    {
                        parameter.SourceExpression = sourceExpression;
                    }
                    else
                    {
                        parameter.Source = source;
                    }

                    parameter.Target = target;

                    ((CallActivity)parentElement).OutParameters.Add(parameter);
                }
            }
Beispiel #20
0
    private string getActionKey(BaseElement action)
    {
        string actionKey = null;

        switch (action.GetType().ToString())
        {
        case "BasicAction":
            actionKey = ((BasicAction)action).actionType.ToString();
            break;

        case "IfAction":
            actionKey = "If";
            break;

        case "ForAction":
            actionKey = "For";
            break;

        default:
            break;
        }
        return(actionKey);
    }
Beispiel #21
0
        public void TestValidateItemAsList()
        {
            var element       = new BaseElement();
            var parentElement = new BaseElement();

            var listMock = new Mock <IElementList <BaseElement, BaseElement> >(MockBehavior.Strict);

            listMock.SetupGet(l => l.Parent).Returns(parentElement);

            var pageBase = new Mock <IPageElementHandler <BaseElement> >(MockBehavior.Strict);

            pageBase.Setup(p => p.GetElementText(parentElement)).Returns("My Data");

            var propertyData = CreatePropertyData(pageBase, element, (p, f) => f(listMock.Object));

            string actualValue;
            var    result = propertyData.ValidateItem(ItemValidationHelper.Create("MyProperty", "My Data"), out actualValue);

            Assert.IsTrue(result);

            pageBase.VerifyAll();
            listMock.VerifyAll();
        }
Beispiel #22
0
    private void GenerateExit(List <int> availableIndex)
    {
        float       x    = w - 1.5f;
        float       y    = Random.Range(1, h) - 0.5f;
        BaseElement exit = SetElement(GetIndex((int)(x + 0.5), (int)(y - 0.5)), ElementContent.Exit);

        // 设置位置
        exit.transform.position = new Vector3(x, y, 0);
        // 移出1x1单元格碰撞器
        Destroy(exit.GetComponent <BoxCollider2D>());
        // 添加2x2单元格碰撞器
        exit.gameObject.AddComponent <BoxCollider2D>();
        availableIndex.Remove(GetIndex((int)(x + 0.5), (int)(y - 0.5)));
        availableIndex.Remove(GetIndex((int)(x + 0.5), (int)(y + 0.5)));
        availableIndex.Remove(GetIndex((int)(x - 0.5), (int)(y - 0.5)));
        availableIndex.Remove(GetIndex((int)(x - 0.5), (int)(y + 0.5)));
        Destroy(mapArray[(int)(x + 0.5), (int)(y + 0.5)].gameObject);
        Destroy(mapArray[(int)(x - 0.5), (int)(y - 0.5)].gameObject);
        Destroy(mapArray[(int)(x - 0.5), (int)(y + 0.5)].gameObject);
        mapArray[(int)(x + 0.5), (int)(y + 0.5)] = exit;
        mapArray[(int)(x - 0.5), (int)(y - 0.5)] = exit;
        mapArray[(int)(x - 0.5), (int)(y + 0.5)] = exit;
    }
Beispiel #23
0
 /// <summary>
 /// add all attributes from XML to element extensionAttributes (except blackListed).
 /// </summary>
 /// <param name="xtr"> </param>
 /// <param name="element"> </param>
 /// <param name="blackLists"> </param>
 public static void AddCustomAttributes(XMLStreamReader xtr, BaseElement element, params IList <ExtensionAttribute>[] blackLists)
 {
     foreach (var attr in xtr.element.Attributes())
     {
         ExtensionAttribute extensionAttribute = new ExtensionAttribute
         {
             Name  = attr.Name.LocalName,
             Value = attr.Value
         };
         if (!string.IsNullOrWhiteSpace(attr.Name.NamespaceName))
         {
             extensionAttribute.Namespace = attr.Name.NamespaceName;
         }
         if (!string.IsNullOrWhiteSpace(xtr.element.GetPrefixOfNamespace(attr.Name.Namespace)))
         {
             extensionAttribute.NamespacePrefix = xtr.element.GetPrefixOfNamespace(attr.Name.Namespace);
         }
         if (!IsBlacklisted(extensionAttribute, blackLists))
         {
             element.AddAttribute(extensionAttribute);
         }
     }
 }
Beispiel #24
0
        public static int GetInnerElementsCount(BaseElement el)
        {
            int ret = 0;

            if (el is ILabelElement)
            {
                ret++;
            }

            if (el is NodeElement)
            {
                NodeElement nel = (NodeElement)el;
                ret += nel.Connectors.Length;
            }

            //			if (el is IContainer)
            //			{
            //				IContainer cel = (IContainer) el;
            //				ret += cel.Elements.Count;
            //			}

            return(ret);
        }
Beispiel #25
0
        public void TestGetItemAtIndexSuccess()
        {
            var element     = new BaseElement();
            var listElement = new BaseElement();
            var propData    = new Mock <IPropertyData>();
            var page        = new Mock <IPage>(MockBehavior.Strict);
            var listPage    = new Mock <IPage>(MockBehavior.Strict);

            var pageBase = new Mock <IPageElementHandler <BaseElement> >(MockBehavior.Strict);

            pageBase.Setup(p => p.GetPageFromElement(listElement)).Returns(listPage.Object);

            var propertyData = CreatePropertyData(pageBase, element, (p, f) => f(new List <BaseElement> {
                listElement
            }));

            var result = propertyData.GetItemAtIndex(0);

            Assert.AreSame(listPage.Object, result);

            pageBase.VerifyAll();
            page.VerifyAll();
            propData.VerifyAll();
        }
        public void RunDiscovery(string tenant)
        {
            Log.Info("Running discovery");
            BaseElement.WaitForElementPresent(By.XPath($"//div[@id='discovery']//*[contains(text(), '{tenant}')]"), "");
            var tenantLabelButton = new Button(By.XPath($"//div[@id='discovery']//*[contains(text(), '{tenant}')]"),
                                               tenant + " label");

            tenantLabelButton.Move();
            BaseElement.WaitForElementPresent(By.XPath($"//*[contains(text(), '{tenant}')]/ancestor::tr//a[contains(@data-bind, 'startDiscovery')]"), "");
            BaseElement.WaitForElementIsClickable(By.XPath($"//*[contains(text(), '{tenant}')]/ancestor::tr//a[contains(@data-bind, 'startDiscovery')]"));
            var runDiscoveryButton =
                new Button(By.XPath($"//*[contains(text(), '{tenant}')]/ancestor::tr//a[contains(@data-bind, 'startDiscovery')]"),
                           tenant + " settings button");

            try
            {
                runDiscoveryButton.Click();
            }
            catch (Exception)
            {
                Log.Info("Run discovery button does not appear");
                discoveryTabButton.Move();
                Thread.Sleep(1000);
                tenantLabelButton.Move();
            }
            try
            {
                Log.Info("Waiting till progress start");
                Label progressSpinerLabel = new Label(By.XPath($"//*[contains(text(), '{tenant}')]/ancestor::tr//i[contains(@class, 'fa-spinner')] | //*[contains(text(), '{tenant}')]/ancestor::tr//i//div[contains(@class, 'sk-spinner')]"), "Progress spinner for: " + tenant);
                progressSpinerLabel.WaitForElementPresent(60000);
            }
            catch (Exception)
            {
                runDiscoveryButton.Click();
            }
        }
Beispiel #27
0
        private void StartSelectElements(BaseElement selectedElement, Point mousePoint)
        {
            // Vefiry if element is in selection
            if (!Document.SelectedElements.Contains(selectedElement))
            {
                //Clear selection and add new element to selection
                Document.ClearSelection();
                Document.SelectElement(selectedElement);
            }

            _changed = false;


            _moveAction = new MoveAction();
            MoveAction.OnElementMovingDelegate onElementMovingDelegate = OnElementMoving;
            _moveAction.Start(mousePoint, Document, onElementMovingDelegate);


            // Get Controllers
            _controllers = new IController[Document.SelectedElements.Count];
            for (var i = Document.SelectedElements.Count - 1; i >= 0; i--)
            {
                if (Document.SelectedElements[i] is IControllable)
                {
                    // Get General Controller
                    _controllers[i] = ((IControllable)Document.SelectedElements[i]).GetController();
                }
                else
                {
                    _controllers[i] = null;
                }
            }

            _resizeAction = new ResizeAction();
            _resizeAction.Select(Document);
        }
Beispiel #28
0
    /// <summary>
    /// Populate the scene with quads
    /// </summary>
    private void PopulateScene()
    {
        foreach (GameObject _current in poolPrefabs)
        {
            for (int i = 0; i < quadInScene / 3; i++)
            {
                BaseElement _el = GetObjectFormPool(_current.GetComponent <BaseElement>().GetElementType());

                if (!placeEl(_el))
                {
                    i--;
                }
                else
                {
                    activeQuads.Add(_el);
                }
            }
        }

        /*
         * // DEBUG only red
         * GameObject _current = poolPrefabs[0];
         * for (int i = 0; i < quadInScene / 3; i++)
         * {
         *  BaseQuad _el = GetObjectFormPool(_current.GetComponent<BaseQuad>().GetQuadType());
         *
         *  if (!placeEl(_el))
         *  {
         *      i--;
         *  }
         *  else
         *  {
         *      activeQuads.Add(_el);
         *  }
         * }*/
    }
Beispiel #29
0
        private void htmluiControl1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            BaseElement elem = this.htmluiControl1.GetElementAtClientPoint(e.X, e.Y) as BaseElement;

            if (elem.Attributes.Contains("class") == false)
            {
                elem.Attributes.Add("class");
            }
            if (elem.Attributes["class"] != null)
            {
                if (radioButton1.Checked == true)
                {
                    elem.Attributes["class"].Value = "tttRed";
                }
                else if (radioButton2.Checked == true)
                {
                    elem.Attributes["class"].Value = "tttBlack";
                }
                else
                {
                    MessageBox.Show("Check a style for the elements display.");
                }
            }
        }
    public static void AddElement(BaseElement _element)
    {
        // add new eleent to lists
        if (_element._id < 0) {
            _element._id = ElementsManager.inst.GetNewID ();
            ElementsManager.inst.ids.Add (_element._id);
            gameElements.Add (_element._id, _element);
        } else if (_element.id > 0) {
            if (!ElementsManager.inst.ids.Contains (_element._id)) {
                ElementsManager.inst.ids.Add (_element._id);
            }
            else{
                _element._id = ElementsManager.inst.GetNewID ();
                ElementsManager.inst.ids.Add (_element._id);
                gameElements.Add (_element._id, _element);
            }

        }

        ElementsBody eb = _element as ElementsBody;
        if (eb != null) {
            ElementsManager.inst.bodyids.Add(eb.id);
        }
    }
Beispiel #31
0
        public void TestValidateItemWhereElementDoesNotExist()
        {
            var element  = new BaseElement();
            var pageBase = new Mock <IPageElementHandler <BaseElement> >(MockBehavior.Strict);

            pageBase.SetupGet(p => p.PageType).Returns(typeof(TestBase));
            pageBase.Setup(p => p.ElementExistsCheck(element)).Returns(false);

            var propertyData = CreatePropertyData(pageBase, element);

            Assert.Throws <ElementExecuteException>(() =>
            {
                string actualValue;
                ExceptionHelper.SetupForException <ElementExecuteException>(
                    () =>
                    propertyData
                    .ValidateItem(ItemValidationHelper.Create("MyField", "My Data"),
                                  out
                                  actualValue),
                    e =>
                    pageBase
                    .VerifyAll());
            });
        }
Beispiel #32
0
        public bool ApplyGameRules()
        {
            int gameEndCombinations = GameEndIndexes.Length / 3;

            for (int i = 0; i < gameEndCombinations; i++)
            {
                BaseElement element1 = _elementArray[GameEndIndexes[i, 0]];
                BaseElement element2 = _elementArray[GameEndIndexes[i, 1]];
                BaseElement element3 = _elementArray[GameEndIndexes[i, 2]];

                if (element1.InnerHTML != "" && element2.InnerHTML != "" && element3.InnerHTML != "")
                {
                    if (element1.InnerHTML == element2.InnerHTML && element1.InnerHTML == element3.InnerHTML)
                    {
                        element1.Attributes["class"].Value = "tttWinDisplay";
                        element2.Attributes["class"].Value = "tttWinDisplay";
                        element3.Attributes["class"].Value = "tttWinDisplay";
                        gameOver = true;
                        break;
                    }
                }
            }
            return(false);
        }
Beispiel #33
0
    /// <summary>
    /// Place an element in scene
    /// </summary>
    /// <param name="_el">element to place</param>
    /// <returns>true if the quad has been successfully placed</returns>
    private bool placeEl(BaseElement _el)
    {
        // get a random position
        float   screenX = Random.Range(5f, Camera.main.pixelWidth - 5f);
        float   screenY = Random.Range(5f, Camera.main.pixelHeight - 5f);
        Vector3 point   = Camera.main.ScreenToWorldPoint(new Vector3(screenX, screenY, 10));

        // check if there are intersection with existing quads
        foreach (BaseElement _temp in activeQuads)
        {
            Bounds _b = _temp.GetCollider().bounds;
            _b.Expand(1f);
            if (_b.Contains(point))
            {
                return(false);
            }
        }

        // set the position
        _el.transform.position = point;
        // start moving
        _el.Move();
        return(true);
    }
 public void ProcessElement(BaseActivityElement _baseElement)
 {
     if ((processActivityElement == null) ||
         (processActivityElement != null && _baseElement != processActivityElement)) {
         processActivityElement = _baseElement;
         ElementEditor.inst.processActivityElement = _baseElement;
         processElement = _baseElement;
         ShowInfoSlots();
     }
 }
	public BaseElement GetTopElements(int num){
		BaseElement topElement = new BaseElement();
		List <int> processedIDs = new List<int> (functionStimuls [FunctionType.Movement].Keys);
		processedEls.Clear ();
		processedEls = new List<float> (functionStimuls [FunctionType.Movement].Values);
		float maxPriority = 0.0f;
		float lowerMargin = 0.0f;
		int selectedEl = -1;
		for (int i = 0; i < processedEls.Count; i++) {
			if(processedEls[i] > maxPriority){
				selectedEl = i;
				maxPriority = processedEls[i];
			}				
		}
		if (selectedEl >= 0)
			return ElementsManager.gameElements[processedIDs[selectedEl]];
		else
			return null;
	}
    void PreparePropertyEditSlots(BaseElement _be)
    {
        Transform[] tr = propertiesEditTable.gameObject.GetComponentsInChildren<Transform> ();
        for (int i = 1; i < tr.Length; i++) {
            Destroy(tr[i].gameObject);
        }
        propEditSlots.Clear ();
        //show already available properties
        for (int i = 0; i < _be.propertiesList.Count; i++) {
            GameObject _slot = Instantiate(propertyEditPrefab, Vector3.zero, Quaternion.identity) as GameObject;
            _slot.transform.SetParent(propertiesEditTable.transform);
            _slot.GetComponent<RectTransform>().localScale = Vector3.one;
            BaseSlot _bs = _slot.GetComponent<BaseSlot>();
            propEditSlots.Add(_bs);
            _bs.GetSlotElement(SlotElemetType.Title).text.text = GlobalData.inst.GetDataBlock(_be.propertiesList[i].propType).name;
            _bs.GetSlotElement(SlotElemetType.Value).text.text = _be.propertiesList[i].val.ToString() + " / " + _be.propertiesList[i].maxVal.ToString();

            EditedOnjectIdentificator editedObj = _slot.GetComponent<EditedOnjectIdentificator>();
            editedObj.SetIdentificator(_be.propertiesList[i]);
        }
        //now list  other properties that can be edited
        PropertyType[] propTypes = (PropertyType[])System.Enum.GetValues (typeof(PropertyType));
        for (int i = 0; i < propTypes.Length; i++) {
            if(!processActivityElement.elProperties.ContainsKey(propTypes[i])){
                GameObject _slot = Instantiate(propertyAddEditPrefab, Vector3.zero, Quaternion.identity) as GameObject;
                _slot.transform.SetParent(propertiesEditTable.transform);
                _slot.GetComponent<RectTransform>().localScale = Vector3.one;
                BaseSlot _bs = _slot.GetComponent<BaseSlot>();
                propEditSlots.Add(_bs);
                _bs.GetSlotElement(SlotElemetType.Title).text.text = GlobalData.inst.GetDataBlock(propTypes[i]).name;
                //_bs.GetSlotElement(SlotElemetType.Value).text.text = _be.propertiesList[i].val.ToString() + " / " + _be.propertiesList[i].maxVal.ToString();

                EditedOnjectIdentificator editedObj = _slot.GetComponent<EditedOnjectIdentificator>();
                BaseElementProperty newProp = new BaseElementProperty();
                newProp.propType = propTypes[i];
                editedObj.SetIdentificator(newProp);
            }
        }
    }
    void PreparePropertyInfoSlots(BaseElement _be)
    {
        Transform[] tr = propertiesInfoTable.gameObject.GetComponentsInChildren<Transform> ();
        for (int i = 1; i < tr.Length; i++) {
            Destroy(tr[i].gameObject);
        }
        propInfoSlots.Clear ();

        for (int i = 0; i < _be.propertiesList.Count; i++) {
            GameObject _slot = Instantiate(propertyInfoPrefab, Vector3.zero, Quaternion.identity) as GameObject;
            _slot.transform.SetParent(propertiesInfoTable.transform);
            _slot.GetComponent<RectTransform>().localScale = Vector3.one;
            BaseSlot _bs = _slot.GetComponent<BaseSlot>();
            propInfoSlots.Add(_bs);
            _bs.GetSlotElement(SlotElemetType.Title).text.text = GlobalData.inst.GetDataBlock(_be.propertiesList[i].propType).name;
            _bs.GetSlotElement(SlotElemetType.Value).text.text = _be.propertiesList[i].val.ToString() + " / " + _be.propertiesList[i].maxVal.ToString();

            EditedOnjectIdentificator editedObj = _slot.GetComponent<EditedOnjectIdentificator>();
            editedObj.SetIdentificator(_be.propertiesList[i]);
        }
    }
 public void ProcessDownPointer()
 {
     BaseElement _agent = GetElement ();
     if (_agent != null) {
         processingAgent = _agent;
         agentSelected = true;
         ShowSelectionDirection(true);
     }
 }
 public void ShowShipControlButtons(BaseElement _agent)
 {
     //		Destroy(agentVC);
     //		processingAgent = null;
     //
     //		processingAgent = _agent;
     //		GameObject tagentVC = Instantiate(agentVCprefab, Vector3.zero, Quaternion.identity) as GameObject;
     //		agentVC = tagentVC;
     //		agentVC.transform.SetParent(HUDsection);
     //		agentVC.transform.localPosition = Vector3.zero;
     //		agentVC.GetComponent<AgentVC>().InitializeVC(_agent, _agent.cTransform, _agent.cRenderer, this);
     //		agentVC.GetComponent<AgentVC>().ShowFulVisualControl();
 }
Beispiel #40
0
        private string GetCommentString(BaseElement be_elem, bool bShowComments, bool bShowNames)
        {
            if (be_elem == null)
                return "";

            string elem_comment = "";
            string elem_name = "";
            string comment = "";

            if (be_elem.Comment != null)
                   elem_comment = be_elem.Comment;

            if (bShowNames) {
                if (be_elem.Name != null)
                    elem_name = be_elem.Name;

                comment = be_elem.Name  + ((elem_comment != String.Empty && bShowComments) ? ": " : "");
            }
            if (bShowComments)
                comment += elem_comment;

            return "//" + comment;
        }
 void EternityGUITester_Click(BaseElement sender, MouseEventArgs e)
 {
     PopupMessage.LocalDisplay("You pressed element " + panel.elements.IndexOf(sender), .1f);
 }
 void panel_ItemClicked(BaseElement sender, MouseEventArgs e)
 {
     PopupMessage.LocalDisplay("You pressed the icon for " + ((ItemElement)sender).item.name);
 }