Inheritance: MonoBehaviour
コード例 #1
0
        private void processToken(StringToken token)
        {
            var text = _repository.FindBy<LocalizedText>(x => x.Name == token.Key && x.Culture == EN_US);
            if (text != null) return;

            Console.WriteLine("Found new StringToken:  " + token.Key);
            text = new LocalizedText(token.Key, EN_US, token.DefaultValue);
            _repository.Save(text);
        }
コード例 #2
0
 public void SetButtonState()
 {
     Text txtField = mc.GetComponentInChildren<Text>();
     LocalizedText localizedText = new LocalizedText(txtField, text);
       /*  RectTransform rectButton = mc.gameObject.GetComponent<RectTransform>();
     RectTransform rectText = txtField.gameObject.GetComponent<RectTransform>();
     rectButton.sizeDelta = new Vector2(rectText.sizeDelta.x, rectButton.sizeDelta.y);
     for (int i = 0; i < mc.transform.childCount; i++)
     {
         if (mc.transform.GetChild(i).tag == "Underline")
         {
             mc.transform.GetChild(i).GetComponent<RectTransform>().sizeDelta = new Vector2(rectText.sizeDelta.x, mc.transform.GetChild(i).GetComponent<RectTransform>().sizeDelta.y);
             mc.transform.GetChild(i).GetComponent<Image>().color = mc.GetComponentInChildren<Text>().color;
         }
     }*/
 }
コード例 #3
0
    public void AddTranslationText(Text _textfield, string txt)
    {
        if (_textfield == null)
            return;

        //Debug.Log("AddTranslationText " + _textfield.name);

        if (localizedTextList.ContainsKey(_textfield))
        {
            LocalizedText _translationText;
            localizedTextList.TryGetValue(_textfield, out _translationText);
            _translationText = new LocalizedText(_textfield, txt);
            //Debug.Log("C?E? GIA? " + _textfield.name);
        }
        else
        {
            localizedTextList.Add(_textfield, new LocalizedText(_textfield, txt));
        }
    }
コード例 #4
0
        /// <summary>
        /// Collects instance declarations nodes from with a type.
        /// </summary>
        public static void CollectInstanceDeclarations(
            Session session,
            ComNamespaceMapper mapper,
            NodeState node,
            AeEventAttribute parent,
            List <AeEventAttribute> instances,
            IDictionary <string, AeEventAttribute> map)
        {
            List <BaseInstanceState> children = new List <BaseInstanceState>();

            node.GetChildren(session.SystemContext, children);

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

            // process the children.
            for (int ii = 0; ii < children.Count; ii++)
            {
                BaseInstanceState instance = children[ii];

                // only interested in objects and variables.
                if (instance.NodeClass != NodeClass.Object && instance.NodeClass != NodeClass.Variable)
                {
                    return;
                }

                // ignore instances without a modelling rule.
                if (NodeId.IsNull(instance.ModellingRuleId))
                {
                    return;
                }

                // create a new declaration.
                AeEventAttribute declaration = new AeEventAttribute();

                declaration.RootTypeId  = (parent != null)?parent.RootTypeId:node.NodeId;
                declaration.NodeId      = (NodeId)instance.NodeId;
                declaration.BrowseName  = instance.BrowseName;
                declaration.NodeClass   = instance.NodeClass;
                declaration.Description = (instance.Description != null)?instance.Description.ToString():null;

                // get data type information.
                BaseVariableState variable = instance as BaseVariableState;

                if (variable != null)
                {
                    declaration.DataType  = variable.DataType;
                    declaration.ValueRank = variable.ValueRank;

                    if (!NodeId.IsNull(variable.DataType))
                    {
                        declaration.BuiltInType = DataTypes.GetBuiltInType(declaration.DataType, session.TypeTree);
                    }
                }

                if (!LocalizedText.IsNullOrEmpty(instance.DisplayName))
                {
                    declaration.DisplayName = instance.DisplayName.Text;
                }
                else
                {
                    declaration.DisplayName = instance.BrowseName.Name;
                }

                if (parent != null)
                {
                    declaration.BrowsePath            = new QualifiedNameCollection(parent.BrowsePath);
                    declaration.BrowsePathDisplayText = Utils.Format("{0}/{1}", parent.BrowsePathDisplayText, mapper.GetLocalBrowseName(instance.BrowseName));
                    declaration.DisplayPath           = Utils.Format("{0}/{1}", parent.DisplayPath, instance.DisplayName);
                }
                else
                {
                    declaration.BrowsePath            = new QualifiedNameCollection();
                    declaration.BrowsePathDisplayText = Utils.Format("{0}", instance.BrowseName);
                    declaration.DisplayPath           = Utils.Format("{0}", instance.DisplayName);
                }

                declaration.BrowsePath.Add(instance.BrowseName);

                // check if reading an overridden declaration.
                AeEventAttribute overriden = null;

                if (map.TryGetValue(declaration.BrowsePathDisplayText, out overriden))
                {
                    declaration.OverriddenDeclaration = overriden;
                }

                map[declaration.BrowsePathDisplayText] = declaration;

                // only interested in variables.
                if (instance.NodeClass == NodeClass.Variable)
                {
                    instances.Add(declaration);
                }

                // recusively build tree.
                CollectInstanceDeclarations(session, mapper, instance, declaration, instances, map);
            }
        }
コード例 #5
0
        public override void OnActivate(int pinID)
        {
            string str = "english";

            switch (pinID)
            {
            case 1:
                str = "english";
                break;

            case 2:
                str = "japanese";
                break;

            case 3:
                str = "french";
                break;

            case 4:
                str = "german";
                break;

            case 5:
                str = "spanish";
                break;

            case 101:
                SystemLanguage systemLanguage = Application.get_systemLanguage();
                switch (systemLanguage - 10)
                {
                case 0:
                    str = "english";
                    break;

                case 4:
                    str = "french";
                    break;

                case 5:
                    str = "german";
                    break;

                default:
                    if (systemLanguage == 34)
                    {
                        str = "spanish";
                        break;
                    }
                    break;
                }
            }
            if (pinID == 102)
            {
                this.ExecRequest((WebAPI) new ReqSetLanguage(GameUtility.Config_Language, new Network.ResponseCallback(((FlowNode_Network)this).ResponseCallback)));
            }
            else
            {
                GameUtility.Config_Language = str;
                LocalizedText.LanguageCode  = str;
                LocalizedText.UnloadAll();
                this.ActivateOutputLinks(10);
            }
        }
コード例 #6
0
ファイル: ItemTooltip.cs プロジェクト: Neubulae/Sources
 private ItemTooltip(string key)
 {
     this._text = Language.GetText(key);
 }
コード例 #7
0
 public override void OnSuccess(WWWResult www)
 {
     if (Network.IsError)
     {
         Network.EErrCode errCode = Network.ErrCode;
         this.OnRetry();
     }
     else
     {
         WebAPI.JSON_BodyResponse <Json_PendingGachaResponse> res = JSONParser.parseJSONObject <WebAPI.JSON_BodyResponse <Json_PendingGachaResponse> >(www.text);
         DebugUtility.Assert(res != null, "res == null");
         Network.RemoveAPI();
         if (res.body == null)
         {
             return;
         }
         List <GachaDropData> gachaDropDataList = new List <GachaDropData>();
         foreach (Json_DropInfo json in res.body.add)
         {
             GachaDropData gachaDropData = new GachaDropData();
             if (gachaDropData.Deserialize(json))
             {
                 gachaDropDataList.Add(gachaDropData);
             }
         }
         List <GachaDropData> a_dropMails = new List <GachaDropData>();
         if (res.body.add_mail != null)
         {
             foreach (Json_DropInfo json in res.body.add_mail)
             {
                 GachaDropData gachaDropData = new GachaDropData();
                 if (gachaDropData.Deserialize(json))
                 {
                     a_dropMails.Add(gachaDropData);
                 }
             }
         }
         for (int index = 0; index < gachaDropDataList.Count; ++index)
         {
             if (gachaDropDataList[index].type == GachaDropData.Type.ConceptCard)
             {
                 GlobalVars.IsDirtyConceptCardData.Set(true);
                 break;
             }
         }
         GachaReceiptData a_receipt = new GachaReceiptData();
         a_receipt.iname = res.body.gacha.gname;
         int a_redraw_rest = 0;
         if (res.body.rest > 0)
         {
             a_redraw_rest = res.body.rest;
         }
         GachaResultData.Init(gachaDropDataList, a_dropMails, (List <int>)null, a_receipt, false, a_redraw_rest <= 0 ? 0 : 1, a_redraw_rest);
         bool flag = false;
         if ((MonoSingleton <GameManager> .Instance.Player.TutorialFlags & 1L) != 0L)
         {
             string empty = string.Empty;
             if (a_redraw_rest > 0)
             {
                 if (res.body.gacha.time_end > Network.GetServerTime())
                 {
                     flag = true;
                 }
                 else
                 {
                     empty = LocalizedText.Get("sys.GACHA_REDRAW_CAUTION_OUTOF_PERIOD");
                 }
             }
             else
             {
                 empty = LocalizedText.Get("sys.GACHA_REDRAW_CAUTION_LIMIT_UPPER");
             }
             if (!flag)
             {
                 UIUtility.SystemMessage(empty, (UIUtility.DialogResultEvent)(go => this.ExecGacha(res.body.gacha.gname)), (GameObject)null, true, -1);
                 return;
             }
         }
         this.StartCoroutine(this.AsyncGachaResultData(gachaDropDataList));
     }
 }
コード例 #8
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            LocalizationInitializer.Startup();

            Target = target as LocalizedText;

            if (Application.isPlaying)
                return;

            var service = LocalizationService.Instance;

            if (service == null || service.Strings == null)
            {
                var p = EditorGUILayout.TextField("Key", Target.Key);

                if (p != Target.Key)
                {
                    Target.Key = p;
                    EditorUtility.SetDirty(target);
                }

                EditorGUILayout.LabelField("Error ", "LocalizationService Not Found");
            }
            else
            {
                var files = service.StringsByFile.Select(o => o.Key).ToArray();

                var findex = Array.IndexOf(files, Target.File);

                var fi = EditorGUILayout.Popup("File", findex, files);

                if (fi != findex)
                {
                    Target.File = files[fi];
                    EditorUtility.SetDirty(target);
                }

                //
                if (!string.IsNullOrEmpty(Target.File))
                {
                    //filter
                    Target.Filter = EditorGUILayout.TextField("Filter ", Target.Filter);

                    string[] words;

                    if (!string.IsNullOrEmpty(Target.Filter))
                    {
                        words = service.StringsByFile[Target.File].Select(o => o.Key).Where(o => o.Contains(Target.Filter)).ToArray();
                    }
                    else
                    {
                        words = service.StringsByFile[Target.File].Select(o => o.Key).ToArray();
                    }
                    var index = Array.IndexOf(words, Target.Key);

                    var i = EditorGUILayout.Popup("Keys", index, words);

                    if (i != index)
                    {
                        Target.Key = words[i];
                        Target.Value = service.Get(Target.Key, string.Empty);
                        EditorUtility.SetDirty(target);
                    }
                }

            }

            if (!string.IsNullOrEmpty(Target.Value))
            {
                EditorGUILayout.LabelField("Value ", Target.Value);

                Target.GetComponent<UnityEngine.UI.Text>().text = Target.Value;
            }
        }
コード例 #9
0
        /// <summary>
        /// Updates a DataType node in the address space.
        /// </summary>
        public void UpdateDataType(
            NodeId        nodeId,
            LocalizedText displayName,
            LocalizedText description,
            uint          writeMask,
            uint          userWriteMask,
            bool          isAbstract)
        {
            try
            {
                m_lock.Enter();

                IDataType target = GetManagerHandle(nodeId) as IDataType;

                if (target == null)
                {
                    throw ServiceResultException.Create(StatusCodes.BadNodeIdInvalid, "DataType '{0}' does not exist.", nodeId);
                }

                target.DisplayName = displayName;
                target.Description = description;
                target.IsAbstract  = isAbstract;
            }
            finally
            {
                m_lock.Exit();
            } 
        }
コード例 #10
0
 /// <virtual cref="ITranslationManager.Translate(IList{string}, LocalizedText)" />
 public LocalizedText Translate(IList<string> preferredLocales, LocalizedText text)
 {
     return Translate(preferredLocales, text, text.TranslationInfo);
 }
コード例 #11
0
 private void Success()
 {
     ((Behaviour)this).set_enabled(false);
     UIUtility.SystemMessage(LocalizedText.Get("sys.CAPTION_TOWER_RECOVERED"), LocalizedText.Get("sys.MSG_TOWER_RECOVERED", new object[1]
     {
         (object)this.usedCoin.ToString()
     }), (UIUtility.DialogResultEvent)(go => this.ActivateOutputLinks(1)), (GameObject)null, false, -1);
 }
コード例 #12
0
        private void Start()
        {
            this.Chapter = MonoSingleton <GameManager> .Instance.FindArea((string)GlobalVars.SelectedChapter);

            if (this.Chapter == null)
            {
                FlowNode_GameObject.ActivateOutputLinks((Component)this, 101);
            }
            else
            {
                if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.ItemTemplate, (UnityEngine.Object)null) && this.ItemTemplate.get_activeInHierarchy())
                {
                    this.ItemTemplate.SetActive(false);
                }
                if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.Message, (UnityEngine.Object)null))
                {
                    string    str       = (string)null;
                    ItemParam itemParam = (ItemParam)null;
                    int       num1      = 0;
                    if (this.Chapter.keys.Count > 0)
                    {
                        KeyItem key = this.Chapter.keys[0];
                        itemParam = MonoSingleton <GameManager> .Instance.GetItemParam(key.iname);

                        num1 = key.num;
                    }
                    KeyQuestTypes keyQuestType     = this.Chapter.GetKeyQuestType();
                    bool          keyQuestTimeOver = GlobalVars.KeyQuestTimeOver;
                    switch (keyQuestType)
                    {
                    case KeyQuestTypes.Timer:
                        if (this.Chapter.keytime != 0L && itemParam != null)
                        {
                            DateTime dateTime1 = TimeManager.FromUnixTime(0L);
                            DateTime dateTime2;
                            if (this.Chapter.end == 0L)
                            {
                                dateTime2 = TimeManager.FromUnixTime(this.Chapter.keytime);
                            }
                            else
                            {
                                long num2 = Math.Min(this.Chapter.end - TimeManager.FromDateTime(TimeManager.ServerTime), this.Chapter.keytime);
                                dateTime2 = TimeManager.FromUnixTime(num2 >= 0L ? num2 : 0L);
                            }
                            TimeSpan timeSpan = dateTime2 - dateTime1;
                            if (timeSpan.TotalDays >= 1.0)
                            {
                                str = LocalizedText.Get(!keyQuestTimeOver ? "sys.KEYQUEST_UNLCOK_TIMER_D" : "sys.KEYQUEST_TIMEOVER_D", (object)itemParam.name, (object)num1, (object)timeSpan.Days);
                                break;
                            }
                            if (timeSpan.TotalHours >= 1.0)
                            {
                                str = LocalizedText.Get(!keyQuestTimeOver ? "sys.KEYQUEST_UNLCOK_TIMER_H" : "sys.KEYQUEST_TIMEOVER_H", (object)itemParam.name, (object)num1, (object)timeSpan.Hours);
                                break;
                            }
                            str = LocalizedText.Get(!keyQuestTimeOver ? "sys.KEYQUEST_UNLCOK_TIMER_M" : "sys.KEYQUEST_TIMEOVER_M", (object)itemParam.name, (object)num1, (object)Mathf.Max(timeSpan.Minutes, 0));
                            break;
                        }
                        break;

                    case KeyQuestTypes.Count:
                        str = LocalizedText.Get(!keyQuestTimeOver ? "sys.KEYQUEST_UNLCOK_COUNT" : "sys.KEYQUEST_TIMEOVER_COUNT", (object)itemParam.name, (object)num1);
                        break;
                    }
                    this.Message.set_text(str);
                }
                this.Refresh();
            }
        }
コード例 #13
0
        public void Activated(int pinID)
        {
            switch (pinID)
            {
            case 1:
                if (this.Chapter != null && this.Chapter.keys.Count > 0)
                {
                    KeyItem  key = this.Chapter.keys[0];
                    ItemData itemDataByItemId = MonoSingleton <GameManager> .Instance.Player.FindItemDataByItemID(key.iname);

                    if (itemDataByItemId == null || itemDataByItemId.Num < key.num)
                    {
                        UIUtility.SystemMessage(LocalizedText.Get("sys.KEYQUEST_UNLOCK"), LocalizedText.Get("sys.KEYQUEST_OUTOFKEY"), (UIUtility.DialogResultEvent)(go => FlowNode_GameObject.ActivateOutputLinks((Component)this, 101)), (GameObject)null, false, -1);
                        break;
                    }
                    if (!this.Chapter.IsDateUnlock(Network.GetServerTime()))
                    {
                        UIUtility.SystemMessage(LocalizedText.Get("sys.KEYQUEST_UNLOCK"), LocalizedText.Get("sys.QUEST_OUT_OF_DATE"), (UIUtility.DialogResultEvent)(go => FlowNode_GameObject.ActivateOutputLinks((Component)this, 101)), (GameObject)null, false, -1);
                        break;
                    }
                }
                GlobalVars.KeyQuestTimeOver = false;
                FlowNode_GameObject.ActivateOutputLinks((Component)this, 100);
                break;

            case 2:
                GlobalVars.KeyQuestTimeOver = false;
                FlowNode_GameObject.ActivateOutputLinks((Component)this, 101);
                break;
            }
        }
コード例 #14
0
        private void DiscoveryTreeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            try
            {
                if (RootFolders.LocalMachine.Equals(e.Node.Tag))
                {
                    ServersTable.Rows.Clear();
                    ShowPanel(true);

                    if (e.Node.Nodes.Count == 1 && String.IsNullOrEmpty(e.Node.Nodes[0].Text))
                    {
                        e.Node.Nodes.Clear();

                        m_lds.BeginFindServers(
                            OnFindServersComplete,
                            new ExpandNodeData()
                        {
                            Parent = e.Node, Lds = m_lds
                        });
                    }
                    else
                    {
                        ShowApplicationDescriptions(e.Node.Nodes);
                    }

                    return;
                }

                if (RootFolders.LocalNetwork.Equals(e.Node.Tag))
                {
                    ServersTable.Rows.Clear();
                    ShowPanel(true);

                    if (e.Node.Nodes.Count == 1 && String.IsNullOrEmpty(e.Node.Nodes[0].Text))
                    {
                        e.Node.Nodes.Clear();

                        m_lds.BeginFindServersOnNetwork(
                            0,
                            1000,
                            OnFindServersOnNetworkComplete,
                            new ExpandNodeData()
                        {
                            Parent = e.Node, Lds = m_lds
                        });
                    }
                    else
                    {
                        ShowServerOnNetworks(e.Node.Nodes);
                    }

                    return;
                }

                if (RootFolders.GlobalDiscovery.Equals(e.Node.Tag))
                {
                    ServersTable.Rows.Clear();
                    ShowPanel(true);

                    if (e.Node.Nodes.Count == 1 && String.IsNullOrEmpty(e.Node.Nodes[0].Text))
                    {
                        e.Node.Nodes.Clear();

                        var servers = new ViewServersOnNetworkDialog(m_gds).ShowDialog(this, ref m_filters);

                        if (servers != null)
                        {
                            foreach (var server in servers)
                            {
                                TreeNode node = new TreeNode(String.Format("{0}", server.ServerName));
                                node.SelectedImageIndex = node.ImageIndex = ImageIndex.Server;
                                node.Tag = server;
                                node.Nodes.Add(new TreeNode());
                                e.Node.Nodes.Add(node);
                            }
                        }
                    }

                    ShowServerOnNetworks(e.Node.Nodes);

                    return;
                }

                if (RootFolders.CustomDiscovery.Equals(e.Node.Tag))
                {
                    ServersTable.Rows.Clear();
                    ShowPanel(true);
                    return;
                }

                if (e.Node.Tag is ApplicationDescription)
                {
                    EndpointsTable.Rows.Clear();
                    ShowPanel(false);

                    ApplicationDescription application = (ApplicationDescription)e.Node.Tag;

                    ApplicationNameTextBox.Text = (LocalizedText.IsNullOrEmpty(application.ApplicationName))?"---":application.ApplicationName.Text;
                    ApplicationTypeTextBox.Text = application.ApplicationType.ToString();
                    ApplicationUriTextBox.Text  = application.ApplicationUri;
                    ProductUriTextBox.Text      = application.ProductUri;

                    string discoveryUrl = SelectDiscoveryUrl(application);

                    if (discoveryUrl != null)
                    {
                        m_lds.BeginGetEndpoints(
                            discoveryUrl,
                            null,
                            OnGetEndpointsComplete,
                            new GetEndpointsData()
                        {
                            Parent = e.Node, Lds = m_lds
                        });
                    }
                }

                if (e.Node.Tag is ServerOnNetwork)
                {
                    EndpointsTable.Rows.Clear();
                    ShowPanel(false);

                    ServerOnNetwork server = (ServerOnNetwork)e.Node.Tag;

                    ApplicationNameTextBox.Text = server.ServerName;
                    ApplicationTypeTextBox.Text = "---";
                    ApplicationUriTextBox.Text  = "---";
                    ProductUriTextBox.Text      = "---";

                    try
                    {
                        Cursor = Cursors.WaitCursor;

                        m_lds.BeginGetEndpoints(
                            server.DiscoveryUrl,
                            null,
                            OnGetEndpointsComplete,
                            new GetEndpointsData()
                        {
                            Parent = e.Node, Lds = m_lds
                        });
                    }
                    finally
                    {
                        Cursor = Cursors.Default;
                    }
                }

                if (e.Node.Tag is ConfiguredEndpoint)
                {
                    EndpointsTable.Rows.Clear();
                    ShowPanel(false);

                    ConfiguredEndpoint server = (ConfiguredEndpoint)e.Node.Tag;

                    ApplicationNameTextBox.Text = "---";
                    ApplicationTypeTextBox.Text = "---";
                    ApplicationUriTextBox.Text  = "---";
                    ProductUriTextBox.Text      = "---";

                    m_lds.BeginGetEndpoints(
                        server.EndpointUrl.ToString(),
                        null,
                        OnGetEndpointsComplete,
                        new GetEndpointsData()
                    {
                        Parent = e.Node, Lds = m_lds
                    });
                }
            }
            catch (Exception ex)
            {
                Opc.Ua.Client.Controls.ExceptionDlg.Show(Text, ex);
            }
        }
コード例 #15
0
ファイル: DataListCtrl.cs プロジェクト: OPCFoundation/UA-.NET
        private void EditMI_Click(object sender, EventArgs e)
        {
            try
            {
                if (ItemsLV.SelectedItems.Count != 1)
                {
                    return;
                }

                ValueState state = ItemsLV.SelectedItems[0].Tag as ValueState;

                if (!IsEditableType(state.Component))
                {
                    return;
                }

                object value = null;
                if (state.Component is LocalizedText)
                {
                    value = new StringValueEditDlg().ShowDialog(state.Component.ToString());
                    if (value != null)
                    {
                        value = new LocalizedText(((LocalizedText)state.Component).Key, ((LocalizedText)state.Component).Locale, value.ToString());
                    }
                }
                else
                {
                    value = new SimpleValueEditDlg().ShowDialog(state.Component, state.Component.GetType());
                }

                if (value == null)
                {
                    return;
                }

                if (state.Value is IEncodeable)
                {
                    PropertyInfo property = (PropertyInfo)state.ComponentId;
                    
                    MethodInfo[] accessors = property.GetAccessors();

                    for (int ii = 0; ii < accessors.Length; ii++)
                    {
                        if (accessors[ii].ReturnType == typeof(void))
                        {
                            accessors[ii].Invoke(state.Value, new object[] { value });
                            state.Component = value;
                            break;
                        }
                    }
                }
                
                DataValue datavalue = state.Value as DataValue;

                if (datavalue != null)
                {
                    int component = (int)state.ComponentId;

                    switch (component)
                    {
                        case 0: { datavalue.Value = value; break; }
                    }
                }

                if (state.Value is IList)
                {
                    int ii = (int)state.ComponentId;
                    ((IList)state.Value)[ii] = value;
                    state.Component = value;
                }
                
                m_expanding = false;
                int index = (int)state.ComponentIndex;
                int indentCount = ItemsLV.Items[index].IndentCount;

                while (ItemsLV.Items[index - 1].IndentCount == indentCount)
                {
                    --index;
                }

                bool overwrite = true;
                ShowValue(ref index, ref overwrite, state.Value);                
            }
            catch (Exception exception)
            {
                GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }
        }
コード例 #16
0
ファイル: PseudoRandom.cs プロジェクト: yuriik83/UA-.NET
        /// <summary>
        /// Returns a expanded node id array.
        /// </summary>
        public LocalizedText[] GetLocalizedTextArray()
        {
            int length = GetInt32Range(-1, m_context.MaxArrayLength);

            if (length < 0)
            {
                return null;
            }

            LocalizedText[] value = new LocalizedText[length];

            for (int ii = 0; ii < value.Length; ii++)
            {
                value[ii] = GetLocalizedText();
            }

            return value;
        }
コード例 #17
0
ファイル: UIText.cs プロジェクト: egshels/Sources
 public void SetText(LocalizedText text, float textScale, bool large)
 {
     InternalSetText(text, textScale, large);
 }
コード例 #18
0
 public void AddAlias(LocalizedText text, NetworkText result)
 {
     this._aliases[text] = result;
 }
コード例 #19
0
        public virtual NodeId RegisterApplication(
            ApplicationRecordDataType application
            )
        {
            if (application == null)
            {
                throw new ArgumentNullException(nameof(application));
            }

            if (application.ApplicationUri == null)
            {
                throw new ArgumentNullException("ApplicationUri");
            }

            if (!Uri.IsWellFormedUriString(application.ApplicationUri, UriKind.Absolute))
            {
                throw new ArgumentException(application.ApplicationUri + " is not a valid URI.", "ApplicationUri");
            }

            if (application.ApplicationType < ApplicationType.Server || application.ApplicationType > ApplicationType.DiscoveryServer)
            {
                throw new ArgumentException(application.ApplicationType.ToString() + " is not a valid ApplicationType.", "ApplicationType");
            }

            if (application.ApplicationNames == null || application.ApplicationNames.Count == 0 || LocalizedText.IsNullOrEmpty(application.ApplicationNames[0]))
            {
                throw new ArgumentException("At least one ApplicationName must be provided.", "ApplicationNames");
            }

            if (String.IsNullOrEmpty(application.ProductUri))
            {
                throw new ArgumentException("A ProductUri must be provided.", "ProductUri");
            }

            if (!Uri.IsWellFormedUriString(application.ProductUri, UriKind.Absolute))
            {
                throw new ArgumentException(application.ProductUri + " is not a valid URI.", "ProductUri");
            }

            if (application.DiscoveryUrls != null)
            {
                foreach (var discoveryUrl in application.DiscoveryUrls)
                {
                    if (String.IsNullOrEmpty(discoveryUrl))
                    {
                        continue;
                    }

                    if (!Uri.IsWellFormedUriString(discoveryUrl, UriKind.Absolute))
                    {
                        throw new ArgumentException(discoveryUrl + " is not a valid URL.", "DiscoveryUrls");
                    }
                }
            }

            if (application.ApplicationType != ApplicationType.Client)
            {
                if (application.DiscoveryUrls == null || application.DiscoveryUrls.Count == 0)
                {
                    throw new ArgumentException("At least one DiscoveryUrl must be provided.", "DiscoveryUrls");
                }

                if (application.ServerCapabilities == null || application.ServerCapabilities.Count == 0)
                {
                    application.ServerCapabilities = new StringCollection()
                    {
                        "NA"
                    };
                }
            }
            else
            {
                if (application.DiscoveryUrls != null && application.DiscoveryUrls.Count > 0)
                {
                    throw new ArgumentException("DiscoveryUrls must not be specified for clients.", "DiscoveryUrls");
                }
            }

            NodeId nodeId = new NodeId();

            if (!NodeId.IsNull(application.ApplicationId))
            {
                // verify node integrity
                switch (application.ApplicationId.IdType)
                {
                case IdType.Guid:
                    nodeId = new NodeId((Guid)application.ApplicationId.Identifier, NamespaceIndex);
                    break;

                case IdType.String:
                    nodeId = new NodeId((string)application.ApplicationId.Identifier, NamespaceIndex);
                    break;

                default:
                    throw new ArgumentException("The ApplicationId has invalid type {0}", application.ApplicationId.ToString());
                }
            }

            return(nodeId);
        }
コード例 #20
0
ファイル: DataListCtrl.cs プロジェクト: yuriik83/UA-.NET
        /// <summary>
        /// Shows localized text in the control. 
        /// </summary>
        private void ShowValue(ref int index, ref bool overwrite, LocalizedText value, int component)
        {      
            string name = null;
            object componentValue = null;

            switch (component)
            {
                case 0:
                {
                    name = "Text";
                    componentValue = value.Text;
                    break;
                }

                case 1:
                {
                    name = "Locale";
                    componentValue = value.Locale;
                    break;
                }
            }

            // don't display empty components.
            if (name == null)
            {
                return;
            }

            // get the type name.
            string type = "(unknown)";

            if (componentValue != null)
            {
                type = componentValue.GetType().Name;
            }
           
            // update the list view.
            UpdateList(
                ref index,
                ref overwrite,
                value,
                componentValue,
                component,
                name,
                type);
        }
コード例 #21
0
        public void UpdateValue()
        {
            GiftRecieveItemData dataOfClass = DataSource.FindDataOfClass <GiftRecieveItemData>(((Component)this).get_gameObject(), (GiftRecieveItemData)null);

            if (dataOfClass == null)
            {
                return;
            }
            string path   = (string)null;
            Sprite sprite = (Sprite)null;
            string str1   = (string)null;
            string str2   = (string)null;

            switch (dataOfClass.type)
            {
            case GiftTypes.Item:
            case GiftTypes.Unit:
                ItemParam itemParam1 = MonoSingleton <GameManager> .Instance.GetItemParam(dataOfClass.iname);

                path   = this.GetIconPath(itemParam1);
                sprite = this.GetFrameSprite(itemParam1, dataOfClass.rarity);
                str1   = this.GetName(itemParam1);
                str2   = dataOfClass.num.ToString();
                break;

            case GiftTypes.Artifact:
                ArtifactParam artifactParam = MonoSingleton <GameManager> .Instance.MasterParam.GetArtifactParam(dataOfClass.iname);

                path   = this.GetIconPath(artifactParam);
                sprite = this.GetFrameSprite(artifactParam, dataOfClass.rarity);
                str1   = this.GetName(artifactParam);
                str2   = dataOfClass.num.ToString();
                break;

            case GiftTypes.Award:
                ItemParam itemParam2 = MonoSingleton <GameManager> .Instance.GetAwardParam(dataOfClass.iname).ToItemParam();

                path             = this.GetIconPath(itemParam2);
                sprite           = this.GetFrameSprite(itemParam2, dataOfClass.rarity);
                str1             = LocalizedText.Get("sys.MAILBOX_ITEM_AWARD_RECEIVE") + this.GetName(itemParam2);
                this.HideNumText = false;
                break;

            case GiftTypes.ConceptCard:
                ConceptCardParam conceptCardParam = MonoSingleton <GameManager> .Instance.MasterParam.GetConceptCardParam(dataOfClass.iname);

                path   = this.GetIconPath(conceptCardParam);
                sprite = this.GetFrameSprite(conceptCardParam, dataOfClass.rarity);
                str1   = this.GetName(conceptCardParam);
                str2   = dataOfClass.num.ToString();
                break;
            }
            if (Object.op_Inequality((Object)this.Icon, (Object)null))
            {
                MonoSingleton <GameManager> .Instance.ApplyTextureAsync(this.Icon, path);
            }
            if (Object.op_Inequality((Object)this.Frame, (Object)null))
            {
                this.Frame.set_sprite(sprite);
            }
            if (Object.op_Inequality((Object)this.NameText, (Object)null))
            {
                this.NameText.set_text(str1);
            }
            if (Object.op_Inequality((Object)this.NumText, (Object)null))
            {
                this.NumText.set_text(str2);
            }
            if (!this.EnableSwapIconFramePriority)
            {
                return;
            }
            if (dataOfClass.type == GiftTypes.ConceptCard)
            {
                this.SwapIconFramePriority(false);
            }
            else
            {
                this.SwapIconFramePriority(true);
            }
        }
コード例 #22
0
        /// <summary>
        /// Updates the object based from a configuration.
        /// </summary>
        public virtual void Create(
            NodeId          parentId,
            NodeId          referenceTypeId, 
            NodeId          nodeId,
            QualifiedName   browseName, 
            uint            numericId,
            object          configuration)
        {         
            CheckNodeManagerState();

            lock (DataLock)
            {
                // update the node id.
                if (NodeId.IsNull(nodeId))
                {
                    nodeId = m_nodeId;
                }
                else
                {                        
                    m_nodeId = nodeId;
                }

                // update the browse name.
                if (QualifiedName.IsNull(browseName))
                {
                    browseName = m_browseName;
                }
                else
                {                        
                    m_browseName = browseName;

                    if (!QualifiedName.IsNull(browseName))
                    {
                        m_displayName = new LocalizedText(browseName.Name);
                    }
                }

                // save the numeric id.
                if (numericId != 0)
                {
                    m_numericId = numericId;
                }

                // do any pre-create processing.
                configuration = OnBeforeCreate(configuration);
                                    
                ILocalNode existingNode = null;

                // find the node by finding a child of the parent with the same browse path.
                if (NodeId.IsNull(this.NodeId))
                {                   
                    existingNode = NodeManager.GetTargetNode(
                        parentId,
                        referenceTypeId,
                        false,
                        true,
                        browseName);

                    // must assign a node id since one does not already exist.
                    if (existingNode == null)
                    {
                        m_nodeId = NodeManager.CreateUniqueNodeId();
                    }
                    else
                    {
                        m_nodeId = existingNode.NodeId;
                    }
                }

                // find the node with the node id provided.
                else
                {
                    existingNode = NodeManager.GetLocalNode(this.NodeId);
                }

                if (existingNode == null)
                {
                    // create the node.
                    CreateNode(parentId, referenceTypeId);

                    // get the default template created by the node manager.
                    existingNode = NodeManager.GetLocalNode(this.NodeId);
                }   

                // update the attributes.
                UpdateAttributes(existingNode);

                // update the references.
                UpdateReferences(existingNode);
                
                // apply the configuration to the node.
                ApplyConfiguration(configuration);

                // add the source to the address space.
                NodeManager.ReplaceNode(existingNode, this);
                
                // recursively configure the children.
                CreateChildren(configuration);
                
                m_created = true;

                // do any post-configuration processing.
                OnAfterCreate(configuration);
            }
        }
コード例 #23
0
        public static void RefreshModLanguage(GameCulture culture)
        {
            Dictionary <string, LocalizedText> dict = LanguageManager.Instance._localizedTexts;

            foreach (ModItem item in ItemLoader.items)
            {
                LocalizedText text = new LocalizedText(item.DisplayName.Key, item.DisplayName.GetTranslation(culture));
                Lang._itemNameCache[item.item.type] = SetLocalizedText(dict, text);
                text = new LocalizedText(item.Tooltip.Key, item.Tooltip.GetTranslation(culture));
                if (text.Value != null)
                {
                    text = SetLocalizedText(dict, text);
                    Lang._itemTooltipCache[item.item.type] = ItemTooltip.FromLanguageKey(text.Key);
                }
            }
            foreach (var keyValuePair in MapLoader.tileEntries)
            {
                foreach (MapEntry entry in keyValuePair.Value)
                {
                    if (entry.translation != null)
                    {
                        LocalizedText text = new LocalizedText(entry.translation.Key, entry.translation.GetTranslation(culture));
                        SetLocalizedText(dict, text);
                    }
                }
            }
            foreach (var keyValuePair in MapLoader.wallEntries)
            {
                foreach (MapEntry entry in keyValuePair.Value)
                {
                    if (entry.translation != null)
                    {
                        LocalizedText text = new LocalizedText(entry.translation.Key, entry.translation.GetTranslation(culture));
                        SetLocalizedText(dict, text);
                    }
                }
            }
            foreach (ModProjectile proj in ProjectileLoader.projectiles)
            {
                LocalizedText text = new LocalizedText(proj.DisplayName.Key, proj.DisplayName.GetTranslation(culture));
                Lang._projectileNameCache[proj.projectile.type] = SetLocalizedText(dict, text);
            }
            foreach (ModNPC npc in NPCLoader.npcs)
            {
                LocalizedText text = new LocalizedText(npc.DisplayName.Key, npc.DisplayName.GetTranslation(culture));
                Lang._npcNameCache[npc.npc.type] = SetLocalizedText(dict, text);
            }
            foreach (ModBuff buff in BuffLoader.buffs)
            {
                LocalizedText text = new LocalizedText(buff.DisplayName.Key, buff.DisplayName.GetTranslation(culture));
                Lang._buffNameCache[buff.Type] = SetLocalizedText(dict, text);
                text = new LocalizedText(buff.Description.Key, buff.Description.GetTranslation(culture));
                Lang._buffDescriptionCache[buff.Type] = SetLocalizedText(dict, text);
            }
            foreach (Mod mod in loadedMods)
            {
                foreach (ModTranslation translation in mod.translations.Values)
                {
                    LocalizedText text = new LocalizedText(translation.Key, translation.GetTranslation(culture));
                    SetLocalizedText(dict, text);
                }
            }
            LanguageManager.Instance.ProcessCopyCommandsInTexts();
        }
コード例 #24
0
        private void CreateLayoutObject(UnitTobiraConditionWindow.ViewParam view_param)
        {
            if (view_param == null || UnityEngine.Object.op_Equality((UnityEngine.Object) this.mConditionObjectTemplate, (UnityEngine.Object)null) || (UnityEngine.Object.op_Equality((UnityEngine.Object) this.mConditionObjectParent, (UnityEngine.Object)null) || UnityEngine.Object.op_Equality((UnityEngine.Object) this.mConditionLayoutParent, (UnityEngine.Object)null)))
            {
                return;
            }
            GameObject gameObject = (GameObject)UnityEngine.Object.Instantiate <GameObject>((M0)this.mConditionObjectTemplate);

            gameObject.get_transform().SetParent(this.mConditionObjectParent, false);
            gameObject.SetActive(true);
            Transform   transform1  = (Transform)null;
            Transform   transform2  = (Transform)null;
            IEnumerator enumerator1 = gameObject.get_transform().GetEnumerator();

            try
            {
                while (enumerator1.MoveNext())
                {
                    Transform current = (Transform)enumerator1.Current;
                    if (((UnityEngine.Object)current).get_name() == ((UnityEngine.Object) this.mConditionLayoutParent).get_name())
                    {
                        transform2 = current;
                    }
                    if (((UnityEngine.Object)current).get_name() == ((UnityEngine.Object) this.mTitleTextObjectParent).get_name())
                    {
                        transform1 = current;
                    }
                }
            }
            finally
            {
                IDisposable disposable = enumerator1 as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            if (UnityEngine.Object.op_Equality((UnityEngine.Object)transform2, (UnityEngine.Object)null))
            {
                return;
            }
            string      format      = LocalizedText.Get(!view_param.is_clear ? UnitTobiraConditionWindow.STRING_FORMAT_CONDS_NOT_CLEAR : UnitTobiraConditionWindow.STRING_FORMAT_CONDS_CLEAR);
            IEnumerator enumerator2 = transform2.GetEnumerator();

            try
            {
                while (enumerator2.MoveNext())
                {
                    Transform current1 = (Transform)enumerator2.Current;
                    bool      flag     = ((UnityEngine.Object)current1).get_name() == ((UnityEngine.Object) this.mLayoutObjects[(int)view_param.type]).get_name();
                    ((Component)current1).get_gameObject().SetActive(flag);
                    if (flag)
                    {
                        IEnumerator enumerator3 = current1.GetEnumerator();
                        try
                        {
                            while (enumerator3.MoveNext())
                            {
                                Transform current2 = (Transform)enumerator3.Current;
                                ((Component)current2).get_gameObject().SetActive(false);
                                if (((UnityEngine.Object)current2).get_name() == UnitTobiraConditionWindow.HAS_UNIT_OBJECT_NAME)
                                {
                                    ((Component)current2).get_gameObject().SetActive(view_param.has_unit);
                                    IEnumerator enumerator4 = current2.GetEnumerator();
                                    try
                                    {
                                        while (enumerator4.MoveNext())
                                        {
                                            Transform current3 = (Transform)enumerator4.Current;
                                            if (((UnityEngine.Object)current3).get_name() == UnitTobiraConditionWindow.VALUE_TEXT_NAME)
                                            {
                                                ((Text)((Component)current3).GetComponent <Text>()).set_text(string.Format(format, (object)view_param.value));
                                            }
                                            if (((UnityEngine.Object)current3).get_name() == UnitTobiraConditionWindow.VALUE_MAX_TEXT_NAME)
                                            {
                                                ((Text)((Component)current3).GetComponent <Text>()).set_text(view_param.value_max);
                                            }
                                            if (((UnityEngine.Object)current3).get_name() == UnitTobiraConditionWindow.JOB_LEVEL_TEXT_PAREANT_NAME)
                                            {
                                                IEnumerator enumerator5 = current3.GetEnumerator();
                                                try
                                                {
                                                    while (enumerator5.MoveNext())
                                                    {
                                                        Transform current4 = (Transform)enumerator5.Current;
                                                        if (((UnityEngine.Object)current4).get_name() == UnitTobiraConditionWindow.JOB_LEVEL_TEXT_NAME)
                                                        {
                                                            ((Text)((Component)current4).GetComponent <Text>()).set_text(string.Format(format, (object)view_param.value));
                                                        }
                                                        if (((UnityEngine.Object)current4).get_name() == UnitTobiraConditionWindow.JOB_LEVEL_MAX_TEXT_NAME)
                                                        {
                                                            ((Text)((Component)current4).GetComponent <Text>()).set_text(view_param.value_max);
                                                        }
                                                    }
                                                }
                                                finally
                                                {
                                                    IDisposable disposable = enumerator5 as IDisposable;
                                                    if (disposable != null)
                                                    {
                                                        disposable.Dispose();
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    finally
                                    {
                                        IDisposable disposable = enumerator4 as IDisposable;
                                        if (disposable != null)
                                        {
                                            disposable.Dispose();
                                        }
                                    }
                                    if (view_param.type == UnitTobiraConditionWindow.eLayoutType.JobLevel && int.Parse(view_param.value) <= 0)
                                    {
                                        ((Component)current2).get_gameObject().SetActive(false);
                                    }
                                    if (view_param.type == UnitTobiraConditionWindow.eLayoutType.TobiraLevel && view_param.tobira_data == null)
                                    {
                                        ((Component)current2).get_gameObject().SetActive(false);
                                    }
                                }
                                if (((UnityEngine.Object)current2).get_name() == UnitTobiraConditionWindow.NOT_HAS_UNIT_OBJECT_NAME)
                                {
                                    ((Component)current2).get_gameObject().SetActive(!view_param.has_unit);
                                }
                                if (((UnityEngine.Object)current2).get_name() == UnitTobiraConditionWindow.NOT_OPEN_JOB_OBJECT_NAME && view_param.has_unit)
                                {
                                    ((Component)current2).get_gameObject().SetActive(int.Parse(view_param.value) <= 0);
                                }
                                if (((UnityEngine.Object)current2).get_name() == UnitTobiraConditionWindow.NOT_OPEN_TOBIRA_OBJECT_NAME && view_param.has_unit)
                                {
                                    ((Component)current2).get_gameObject().SetActive(view_param.tobira_data == null);
                                }
                            }
                        }
                        finally
                        {
                            IDisposable disposable = enumerator3 as IDisposable;
                            if (disposable != null)
                            {
                                disposable.Dispose();
                            }
                        }
                        if (view_param.unit_data != null)
                        {
                            DataSource.Bind <UnitData>(((Component)current1).get_gameObject(), view_param.unit_data);
                        }
                        if (view_param.job_param != null)
                        {
                            DataSource.Bind <JobParam>(((Component)current1).get_gameObject(), view_param.job_param);
                        }
                        if (view_param.tobira_data != null)
                        {
                            DataSource.Bind <TobiraData>(((Component)current1).get_gameObject(), view_param.tobira_data);
                        }
                        GameParameter.UpdateAll(((Component)current1).get_gameObject());
                    }
                }
            }
            finally
            {
                IDisposable disposable = enumerator2 as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            IEnumerator enumerator6 = transform1.GetEnumerator();

            try
            {
                while (enumerator6.MoveNext())
                {
                    Transform current = (Transform)enumerator6.Current;
                    if (((UnityEngine.Object)current).get_name() == ((UnityEngine.Object) this.mTitleTextObject).get_name())
                    {
                        Text component = (Text)((Component)current).GetComponent <Text>();
                        if (UnityEngine.Object.op_Inequality((UnityEngine.Object)component, (UnityEngine.Object)null))
                        {
                            component.set_text(view_param.title);
                        }
                    }
                    if (((UnityEngine.Object)current).get_name() == ((UnityEngine.Object) this.mIconImageArray).get_name())
                    {
                        int        num       = !view_param.is_clear ? 0 : 1;
                        ImageArray component = (ImageArray)((Component)current).GetComponent <ImageArray>();
                        if (UnityEngine.Object.op_Inequality((UnityEngine.Object)component, (UnityEngine.Object)null))
                        {
                            component.ImageIndex = num;
                        }
                    }
                }
            }
            finally
            {
                IDisposable disposable = enumerator6 as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
        }
コード例 #25
0
 private static LocalizedText SetLocalizedText(Dictionary <string, LocalizedText> dict, LocalizedText value)
 {
     if (dict.ContainsKey(value.Key))
     {
         dict[value.Key].SetValue(value.Value);
     }
     else
     {
         dict[value.Key] = value;
     }
     return(dict[value.Key]);
 }
コード例 #26
0
        /// <summary>
        /// Builds a variant for the data value.
        /// </summary>
        public void BuildDataValue(ref Session session, ref Variant value, NodeId dataTypeId, int valueRank, string newValue)
        {
            BuiltInType builtinType = Opc.Ua.TypeInfo.GetBuiltInType(dataTypeId, session.TypeTree);
            Type        valueType;

            char[]   separator = { ',' };
            string[] newValueStrings;
            if (valueRank == ValueRanks.Scalar)
            {
                newValue = newValue.Trim();
                switch (builtinType)
                {
                case BuiltInType.Byte:
                case BuiltInType.SByte:
                case BuiltInType.Int16:
                case BuiltInType.UInt16:
                case BuiltInType.Int32:
                case BuiltInType.UInt32:
                case BuiltInType.Int64:
                case BuiltInType.UInt64:
                case BuiltInType.Float:
                case BuiltInType.Double:
                {
                    valueType = Opc.Ua.TypeInfo.GetSystemType(builtinType, valueRank);
                    if (valueType == typeof(SByte))
                    {
                        value = new Variant(Convert.ToSByte(newValue, CultureInfo.InvariantCulture));
                    }

                    if (valueType == typeof(Byte))
                    {
                        value = new Variant(Convert.ToByte(newValue, CultureInfo.InvariantCulture));
                    }

                    if (valueType == typeof(Int16))
                    {
                        value = new Variant(Convert.ToInt16(newValue, CultureInfo.InvariantCulture));
                    }

                    if (valueType == typeof(UInt16))
                    {
                        value = new Variant(Convert.ToUInt16(newValue, CultureInfo.InvariantCulture));
                    }

                    if (valueType == typeof(Int32))
                    {
                        value = new Variant(Convert.ToInt32(newValue, CultureInfo.InvariantCulture));
                    }

                    if (valueType == typeof(UInt32))
                    {
                        value = new Variant(Convert.ToUInt32(newValue, CultureInfo.InvariantCulture));
                    }

                    if (valueType == typeof(Int64))
                    {
                        value = new Variant(Convert.ToInt64(newValue, CultureInfo.InvariantCulture));
                    }

                    if (valueType == typeof(UInt64))
                    {
                        value = new Variant(Convert.ToUInt64(newValue, CultureInfo.InvariantCulture));
                    }

                    if (valueType == typeof(Single))
                    {
                        value = new Variant(Convert.ToSingle(newValue, CultureInfo.InvariantCulture));
                    }

                    if (valueType == typeof(Double))
                    {
                        value = new Variant(Convert.ToDouble(newValue, CultureInfo.InvariantCulture));
                    }
                }
                break;

                case BuiltInType.Boolean:
                {
                    value = Convert.ToBoolean(newValue, CultureInfo.InvariantCulture);
                }
                break;

                case BuiltInType.String:
                {
                    value = newValue;
                }
                break;

                case BuiltInType.Guid:
                {
                    value = new Guid(newValue);
                }
                break;

                case BuiltInType.DateTime:
                {
                    value = new Variant(Convert.ToDateTime(newValue, CultureInfo.InvariantCulture));
                }
                break;

                case BuiltInType.ByteString:
                {
                    if (newValue.Length % 2 == 1)
                    {
                        Exception e = new Exception("ByteString must have even length.");
                        throw e;
                    }
                    Byte[] byteArray = new Byte[newValue.Length / 2];
                    for (int ii = 0; ii < newValue.Length; ii += 2)
                    {
                        string byteValue = newValue.Substring(ii, 2);
                        byteArray[ii / 2] = Convert.ToByte(byteValue, 16);
                    }
                    value = new Variant(byteArray);
                }
                break;

                case BuiltInType.XmlElement:
                {
                    string newValueDecoded = HttpUtility.HtmlDecode(newValue);
                    value = (XmlElement)Opc.Ua.TypeInfo.Cast(newValueDecoded, BuiltInType.XmlElement);
                }
                break;

                case BuiltInType.NodeId:
                {
                    NodeId nodeId = new NodeId(newValue.ToString());
                    value = nodeId;
                }
                break;

                case BuiltInType.ExpandedNodeId:
                {
                    ExpandedNodeId nodeId = new ExpandedNodeId(newValue.ToString());
                    value = nodeId;
                }
                break;

                case BuiltInType.QualifiedName:
                {
                    QualifiedName name = new QualifiedName(newValue.ToString());
                    value = name;
                }
                break;

                case BuiltInType.LocalizedText:
                {
                    LocalizedText text = new LocalizedText(newValue.ToString());
                    value = text;
                }
                break;

                case BuiltInType.StatusCode:
                {
                    StatusCode status = new StatusCode(Convert.ToUInt32(newValue, 16));
                    value = status;
                }
                break;

                case BuiltInType.Variant:
                {
                    value = (Variant)Opc.Ua.TypeInfo.Cast(newValue, BuiltInType.Variant);
                }
                break;

                case BuiltInType.Enumeration:
                {
                    value = new Variant(Opc.Ua.TypeInfo.Cast(newValue, BuiltInType.Enumeration));
                }
                break;

                case BuiltInType.ExtensionObject:
                {
                    value = new ExtensionObject(newValue);
                }
                break;

                case BuiltInType.Number:
                case BuiltInType.Integer:
                case BuiltInType.UInteger:
                {
                    value = new Variant(Opc.Ua.TypeInfo.Cast(newValue, builtinType));
                }
                break;
                }
            }
            else if (valueRank == ValueRanks.OneDimension)
            {
                switch (builtinType)
                {
                case BuiltInType.Byte:
                case BuiltInType.SByte:
                case BuiltInType.Int16:
                case BuiltInType.UInt16:
                case BuiltInType.Int32:
                case BuiltInType.UInt32:
                case BuiltInType.Int64:
                case BuiltInType.UInt64:
                case BuiltInType.Float:
                case BuiltInType.Double:
                {
                    valueType = Opc.Ua.TypeInfo.GetSystemType(builtinType, valueRank);
                    if (valueType == typeof(SByte[]))
                    {
                        List <SByte> valList = new List <SByte>();
                        newValueStrings = newValue.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                        for (int i = 0; i < newValueStrings.Length; i++)
                        {
                            valList.Add(Convert.ToSByte(newValueStrings[i], CultureInfo.InvariantCulture));
                        }
                        value = new Variant(valList);
                    }

                    if (valueType == typeof(Byte[]))
                    {
                        List <Byte> valList = new List <Byte>();
                        newValueStrings = newValue.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                        for (int i = 0; i < newValueStrings.Length; i++)
                        {
                            valList.Add(Convert.ToByte(newValueStrings[i], CultureInfo.InvariantCulture));
                        }
                        value = new Variant(valList);
                    }

                    if (valueType == typeof(Int16[]))
                    {
                        List <Int16> valList = new List <Int16>();
                        newValueStrings = newValue.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                        for (int i = 0; i < newValueStrings.Length; i++)
                        {
                            valList.Add(Convert.ToInt16(newValueStrings[i], CultureInfo.InvariantCulture));
                        }
                        value = new Variant(valList);
                    }

                    if (valueType == typeof(UInt16[]))
                    {
                        List <UInt16> valList = new List <UInt16>();
                        newValueStrings = newValue.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                        for (int i = 0; i < newValueStrings.Length; i++)
                        {
                            valList.Add(Convert.ToUInt16(newValueStrings[i], CultureInfo.InvariantCulture));
                        }
                        value = new Variant(valList);
                    }

                    if (valueType == typeof(Int32[]))
                    {
                        List <Int32> valList = new List <Int32>();
                        newValueStrings = newValue.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                        for (int i = 0; i < newValueStrings.Length; i++)
                        {
                            valList.Add(Convert.ToInt32(newValueStrings[i], CultureInfo.InvariantCulture));
                        }
                        value = new Variant(valList);
                    }

                    if (valueType == typeof(UInt32[]))
                    {
                        List <UInt32> valList = new List <UInt32>();
                        newValueStrings = newValue.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                        for (int i = 0; i < newValueStrings.Length; i++)
                        {
                            valList.Add(Convert.ToUInt32(newValueStrings[i], CultureInfo.InvariantCulture));
                        }
                        value = new Variant(valList);
                    }

                    if (valueType == typeof(Int64[]))
                    {
                        List <Int64> valList = new List <Int64>();
                        newValueStrings = newValue.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                        for (int i = 0; i < newValueStrings.Length; i++)
                        {
                            valList.Add(Convert.ToInt64(newValueStrings[i], CultureInfo.InvariantCulture));
                        }
                        value = new Variant(valList);
                    }

                    if (valueType == typeof(UInt64[]))
                    {
                        List <UInt64> valList = new List <UInt64>();
                        newValueStrings = newValue.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                        for (int i = 0; i < newValueStrings.Length; i++)
                        {
                            valList.Add(Convert.ToUInt64(newValueStrings[i], CultureInfo.InvariantCulture));
                        }
                        value = new Variant(valList);
                    }

                    if (valueType == typeof(Single[]))
                    {
                        List <Single> valList = new List <Single>();
                        newValueStrings = newValue.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                        for (int i = 0; i < newValueStrings.Length; i++)
                        {
                            valList.Add(Convert.ToSingle(newValueStrings[i], CultureInfo.InvariantCulture));
                        }
                        value = new Variant(valList);
                    }

                    if (valueType == typeof(Double[]))
                    {
                        List <Double> valList = new List <Double>();
                        newValueStrings = newValue.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                        for (int i = 0; i < newValueStrings.Length; i++)
                        {
                            valList.Add(Convert.ToDouble(newValueStrings[i], CultureInfo.InvariantCulture));
                        }
                        value = new Variant(valList);
                    }
                }
                break;

                case BuiltInType.Boolean:
                {
                    List <Boolean> valList = new List <Boolean>();
                    newValueStrings = newValue.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < newValueStrings.Length; i++)
                    {
                        newValueStrings[i] = newValueStrings[i].Trim();
                        valList.Add(Convert.ToBoolean(newValueStrings[i], CultureInfo.InvariantCulture));
                    }
                    value = new Variant(valList);
                }
                break;

                case BuiltInType.String:
                {
                    List <String> valList = new List <String>();
                    newValueStrings = newValue.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < newValueStrings.Length; i++)
                    {
                        valList.Add(Convert.ToString(newValueStrings[i], CultureInfo.InvariantCulture));
                    }
                    value = new Variant(valList);
                }
                break;

                case BuiltInType.Guid:
                {
                    List <Guid> valList = new List <Guid>();
                    newValueStrings = newValue.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < newValueStrings.Length; i++)
                    {
                        newValueStrings[i] = newValueStrings[i].Trim();
                        valList.Add(new Guid(newValueStrings[i]));
                    }
                    Guid[] valArray = valList.ToArray();
                    value = new Variant(valArray);
                }
                break;

                case BuiltInType.DateTime:
                {
                    List <DateTime> valList = new List <DateTime>();
                    newValueStrings = newValue.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < newValueStrings.Length; i++)
                    {
                        newValueStrings[i] = newValueStrings[i].Trim();
                        valList.Add(Convert.ToDateTime(newValueStrings[i], CultureInfo.InvariantCulture));
                    }
                    value = new Variant(valList);
                }
                break;

                case BuiltInType.ByteString:
                {
                    List <Byte[]> valList = new List <Byte[]>();
                    newValueStrings = newValue.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < newValueStrings.Length; i++)
                    {
                        newValueStrings[i] = newValueStrings[i].Trim();
                        if (newValueStrings[i].Length % 2 == 1)
                        {
                            Exception e = new Exception("ByteString must have even length.");
                            throw e;
                        }
                        Byte[] byteArray = new Byte[newValueStrings[i].Length / 2];
                        for (int ii = 0; ii < newValueStrings[i].Length; ii += 2)
                        {
                            string byteValue = newValueStrings[i].Substring(ii, 2);
                            byteArray[ii / 2] = Convert.ToByte(byteValue, 16);
                        }
                        valList.Add(byteArray);
                    }
                    value = new Variant(valList);
                }
                break;

                case BuiltInType.XmlElement:
                {
                    List <XmlElement> valList = new List <XmlElement>();
                    newValueStrings = newValue.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < newValueStrings.Length; i++)
                    {
                        newValueStrings[i] = newValueStrings[i].Trim();
                        string newValueDecoded = HttpUtility.HtmlDecode(newValueStrings[i]);
                        valList.Add((XmlElement)Opc.Ua.TypeInfo.Cast(newValueDecoded, BuiltInType.XmlElement));
                    }
                    value = new Variant(valList);
                }
                break;

                case BuiltInType.NodeId:
                {
                    List <NodeId> valList = new List <NodeId>();
                    newValueStrings = newValue.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < newValueStrings.Length; i++)
                    {
                        newValueStrings[i] = newValueStrings[i].Trim();
                        valList.Add((NodeId)Opc.Ua.TypeInfo.Cast(newValueStrings[i], BuiltInType.NodeId));
                    }
                    value = new Variant(valList);
                }
                break;

                case BuiltInType.ExpandedNodeId:
                {
                    List <ExpandedNodeId> valList = new List <ExpandedNodeId>();
                    newValueStrings = newValue.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < newValueStrings.Length; i++)
                    {
                        newValueStrings[i] = newValueStrings[i].Trim();
                        valList.Add((ExpandedNodeId)Opc.Ua.TypeInfo.Cast(newValueStrings[i], BuiltInType.ExpandedNodeId));
                    }
                    value = new Variant(valList);
                }
                break;

                case BuiltInType.QualifiedName:
                {
                    List <QualifiedName> valList = new List <QualifiedName>();
                    newValueStrings = newValue.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < newValueStrings.Length; i++)
                    {
                        valList.Add(new QualifiedName(newValueStrings[i]));
                    }
                    value = new Variant(valList);
                }
                break;

                case BuiltInType.LocalizedText:
                {
                    List <LocalizedText> valList = new List <LocalizedText>();
                    newValueStrings = newValue.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < newValueStrings.Length; i++)
                    {
                        valList.Add(new LocalizedText(newValueStrings[i]));
                    }
                    value = new Variant(valList);
                }
                break;

                case BuiltInType.StatusCode:
                {
                    List <StatusCode> valList = new List <StatusCode>();
                    newValueStrings = newValue.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < newValueStrings.Length; i++)
                    {
                        newValueStrings[i] = newValueStrings[i].Trim();
                        valList.Add(new StatusCode(Convert.ToUInt32(newValueStrings[i], 16)));
                    }
                    value = new Variant(valList);
                }
                break;

                case BuiltInType.Variant:
                {
                    List <Variant> valList = new List <Variant>();
                    newValueStrings = newValue.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < newValueStrings.Length; i++)
                    {
                        valList.Add((Variant)Opc.Ua.TypeInfo.Cast(newValueStrings[i], BuiltInType.Variant));
                    }
                    value = new Variant(valList);
                }
                break;

                case BuiltInType.Enumeration:
                {
                    List <Enumeration> valList = new List <Enumeration>();
                    newValueStrings = newValue.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < newValueStrings.Length; i++)
                    {
                        valList.Add((Enumeration)Opc.Ua.TypeInfo.Cast(newValueStrings[i], BuiltInType.Enumeration));
                    }
                    value = new Variant(valList);
                }
                break;

                case BuiltInType.ExtensionObject:
                {
                    List <ExtensionObject> valList = new List <ExtensionObject>();
                    newValueStrings = newValue.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < newValueStrings.Length; i++)
                    {
                        valList.Add((ExtensionObject) new ExtensionObject(newValueStrings[i]));
                    }
                    value = new Variant(valList);
                }
                break;

                case BuiltInType.Number:
                case BuiltInType.Integer:
                case BuiltInType.UInteger:
                {
                    List <Variant> valList = new List <Variant>();
                    newValueStrings = newValue.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < newValueStrings.Length; i++)
                    {
                        newValueStrings[i] = newValueStrings[i].Trim();
                        Variant v = new Variant(Opc.Ua.TypeInfo.Cast(newValueStrings[i], builtinType));
                        valList.Add(v);
                    }
                    value = new Variant(valList);
                }
                break;
                }
            }
            else
            {
                Exception e = new Exception("Value rank " + valueRank.ToString(CultureInfo.CurrentCulture) + " is not supported");
                throw e;
            }
        }
コード例 #27
0
 public UIText(LocalizedText text, float textScale = 1f, bool large = false)
 {
     this.InternalSetText((object)text, textScale, large);
 }
コード例 #28
0
 public TextInTurnsGame(LocalizedText localizedText, LocalizationFile localizationFile)
 {
     this.localizedText    = localizedText;
     this.liked            = false; // TODO: History of likes? (TBD)
     this.localizationFile = localizationFile;
 }
コード例 #29
0
 public void SetText(LocalizedText text)
 {
     this.InternalSetText((object)text, this._textScale, this._isLarge);
 }
コード例 #30
0
        /// <summary>
        /// Collects instance declarations nodes from with a type.
        /// </summary>
        public static void CollectInstanceDeclarations(
            Session session,
            ComNamespaceMapper mapper,
            NodeId typeId,
            AeEventAttribute parent,
            List <AeEventAttribute> instances,
            IDictionary <string, AeEventAttribute> map)
        {
            // find the children.
            BrowseDescription nodeToBrowse = new BrowseDescription();

            if (parent == null)
            {
                nodeToBrowse.NodeId = typeId;
            }
            else
            {
                nodeToBrowse.NodeId = parent.NodeId;
            }

            nodeToBrowse.BrowseDirection = BrowseDirection.Forward;
            nodeToBrowse.ReferenceTypeId = ReferenceTypeIds.HasChild;
            nodeToBrowse.IncludeSubtypes = true;
            nodeToBrowse.NodeClassMask   = (uint)(NodeClass.Object | NodeClass.Variable);
            nodeToBrowse.ResultMask      = (uint)BrowseResultMask.All;

            // ignore any browsing errors.
            ReferenceDescriptionCollection references = Browse(session, nodeToBrowse, false);

            if (references == null)
            {
                return;
            }

            // process the children.
            List <NodeId>           nodeIds  = new List <NodeId>();
            List <AeEventAttribute> children = new List <AeEventAttribute>();

            for (int ii = 0; ii < references.Count; ii++)
            {
                ReferenceDescription reference = references[ii];

                if (reference.NodeId.IsAbsolute)
                {
                    continue;
                }

                // create a new declaration.
                AeEventAttribute child = new AeEventAttribute();

                child.RootTypeId = typeId;
                child.NodeId     = (NodeId)reference.NodeId;
                child.BrowseName = reference.BrowseName;
                child.NodeClass  = reference.NodeClass;

                if (!LocalizedText.IsNullOrEmpty(reference.DisplayName))
                {
                    child.DisplayName = reference.DisplayName.Text;
                }
                else
                {
                    child.DisplayName = reference.BrowseName.Name;
                }

                if (parent != null)
                {
                    child.BrowsePath            = new QualifiedNameCollection(parent.BrowsePath);
                    child.BrowsePathDisplayText = Utils.Format("{0}/{1}", parent.BrowsePathDisplayText, mapper.GetLocalBrowseName(reference.BrowseName));
                    child.DisplayPath           = Utils.Format("{0}/{1}", parent.DisplayPath, reference.DisplayName);
                }
                else
                {
                    child.BrowsePath            = new QualifiedNameCollection();
                    child.BrowsePathDisplayText = Utils.Format("{0}", reference.BrowseName);
                    child.DisplayPath           = Utils.Format("{0}", reference.DisplayName);
                }

                child.BrowsePath.Add(reference.BrowseName);

                // check if reading an overridden declaration.
                AeEventAttribute overriden = null;

                if (map.TryGetValue(child.BrowsePathDisplayText, out overriden))
                {
                    child.OverriddenDeclaration = overriden;
                }

                map[child.BrowsePathDisplayText] = child;

                // add to list.
                children.Add(child);
                nodeIds.Add(child.NodeId);
            }

            // check if nothing more to do.
            if (children.Count == 0)
            {
                return;
            }

            // find the modelling rules.
            List <NodeId> modellingRules = FindTargetOfReference(session, nodeIds, Opc.Ua.ReferenceTypeIds.HasModellingRule, false);

            if (modellingRules != null)
            {
                for (int ii = 0; ii < nodeIds.Count; ii++)
                {
                    children[ii].ModellingRule = modellingRules[ii];

                    // if the modelling rule is null then the instance is not part of the type declaration.
                    if (NodeId.IsNull(modellingRules[ii]))
                    {
                        map.Remove(children[ii].BrowsePathDisplayText);
                    }
                }
            }

            // update the descriptions.
            UpdateInstanceDescriptions(session, children, false);

            // recusively collect instance declarations for the tree below.
            for (int ii = 0; ii < children.Count; ii++)
            {
                if (!NodeId.IsNull(children[ii].ModellingRule))
                {
                    instances.Add(children[ii]);
                    CollectInstanceDeclarations(session, mapper, typeId, children[ii], instances, map);
                }
            }
        }
コード例 #31
0
 public void SetText(LocalizedText text, float textScale, bool large)
 {
     this.InternalSetText((object)text, textScale, large);
 }
コード例 #32
0
ファイル: LocalizedText.cs プロジェクト: guplem/DrinkExtreme
    public static LocalizedText GetRandomTextWithIdStartingWith(string idBeggining, bool getOldestConsulted, bool useConfigFilters, List <LocalizedText> localizedTextsList)
    {
        DateTime      oldestTimestampFound = DateTime.MinValue;
        LocalizedText oldestTxtFound       = null;

        foreach (LocalizedText txt in localizedTextsList)
        {
            if (txt.id.StartsWith(idBeggining))
            {
                //If it is not necessary to search for the oldest one
                if (!getOldestConsulted)
                {
                    if ((useConfigFilters && IsLocalizedTextAcceptedByConfiguration(txt)) || (!useConfigFilters)) //Txt accepted by the configuration (or not needed to check)
                    {
                        oldestTxtFound       = txt;
                        oldestTimestampFound = txt.lastRequested;
                        break;
                    }
                }
                //Otherwise
                else
                {
                    //If there is no text selected yet as the oldest (to increment the successful return possibilities)
                    if (oldestTxtFound == null)
                    {
                        if ((useConfigFilters && IsLocalizedTextAcceptedByConfiguration(txt)) || (!useConfigFilters)) //Txt accepted by the configuration (or not needed to check)
                        {
                            oldestTxtFound       = txt;
                            oldestTimestampFound = txt.lastRequested;
                        }
                    }

                    //if txt.lastRequested is older than oldestTimestampFound save it
                    if (DateTime.Compare(oldestTimestampFound, txt.lastRequested) > 0)
                    {
                        if ((useConfigFilters && IsLocalizedTextAcceptedByConfiguration(txt)) || (!useConfigFilters))  //Txt accepted by the configuration (or not needed to check)
                        {
                            oldestTimestampFound = txt.lastRequested;
                            oldestTxtFound       = txt;
                        }
                    }

                    //If the txt can not be older than it is exit the search
                    if ((oldestTxtFound != null) && (oldestTimestampFound == DateTime.MinValue))
                    {
                        break;
                    }
                }
            }
        }

        if (oldestTxtFound == null)
        {
            Debug.LogError("No text found with the id begining with '" + idBeggining + "'" + (getOldestConsulted ? " (searching the oldest text consulted)" : ""));
            return(new LocalizedText(idBeggining, "No text found with the id begining with '" + idBeggining + "'" + (useConfigFilters? " with the configured filters" : "")));
        }
        else
        {
            return(oldestTxtFound);
        }
    }
コード例 #33
0
        /// <summary>
        /// Shows a value in control.
        /// </summary>
        private void ShowValue(ref int index, ref bool overwrite, object value)
        {
            if (value == null)
            {
                return;
            }

            // show monitored items.
            MonitoredItem monitoredItem = value as MonitoredItem;

            if (monitoredItem != null)
            {
                m_monitoredItem = monitoredItem;
                ShowValue(ref index, ref overwrite, monitoredItem.LastValue);
                return;
            }            
            
            // show data changes
            MonitoredItemNotification datachange = value as MonitoredItemNotification;

            if (datachange != null)
            {
                ShowValue(ref index, ref overwrite, datachange.Value);
                return;
            }            
            
            // show events
            EventFieldList eventFields = value as EventFieldList;

            if (eventFields != null)
            {                
                for (int ii = 0; ii < eventFields.EventFields.Count; ii++)
                {
                    ShowValue(ref index, ref overwrite, eventFields, ii);
                }

                return;
            }

            // show extension bodies.
            ExtensionObject extension = value as ExtensionObject;

            if (extension != null)
            {
                ShowValue(ref index, ref overwrite, extension.Body);
                return;
            }

            // show encodeables.
            IEncodeable encodeable = value as IEncodeable;

            if (encodeable != null)
            {
                PropertyInfo[] properties = encodeable.GetType().GetProperties();

                foreach (PropertyInfo property in properties)
                {
                    ShowValue(ref index, ref overwrite, encodeable, property);
                }

                return;
            }
                        
            // show bytes.
            byte[] bytes = value as byte[];

            if (bytes != null)
            {
                if (!PromptOnLongList(bytes.Length/16))
                {
                    return;
                }

                for (int ii = 0; ii < bytes.Length; ii+=16)
                {
                    ShowValue(ref index, ref overwrite, bytes, ii);
                }
                
                return;
            }

            // show arrays
            Array array = value as Array;

            if (array != null)
            {
                if (!PromptOnLongList(array.Length))
                {
                    return;
                }

                for (int ii = 0; ii < array.Length; ii++)
                {
                    ShowValue(ref index, ref overwrite, array, ii);
                }

                return;
            }
            
            // show lists
            IList list = value as IList;

            if (list != null)
            {
                if (!PromptOnLongList(list.Count))
                {
                    return;
                }

                for (int ii = 0; ii < list.Count; ii++)
                {
                    ShowValue(ref index, ref overwrite, list, ii);
                }

                return;
            }
            
            // show xml elements
            XmlElement xml = value as XmlElement;
            
            if (xml != null)
            {
                if (!PromptOnLongList(xml.ChildNodes.Count))
                {
                    return;
                }

                for (int ii = 0; ii < xml.ChildNodes.Count; ii++)
                {
                    ShowValue(ref index, ref overwrite, xml, ii);
                }

                return;
            }
            
            // show data value.
            DataValue datavalue = value as DataValue;

            if (datavalue != null)
            {
                ShowValue(ref index, ref overwrite, datavalue, 0);
                ShowValue(ref index, ref overwrite, datavalue, 1);
                ShowValue(ref index, ref overwrite, datavalue, 2);
                ShowValue(ref index, ref overwrite, datavalue, 3);
                return;
            }

            // show node id value.
            NodeId nodeId = value as NodeId;

            if (nodeId != null)
            {
                ShowValue(ref index, ref overwrite, nodeId, 0);
                ShowValue(ref index, ref overwrite, nodeId, 1);
                ShowValue(ref index, ref overwrite, nodeId, 2);
                return;
            }

            // show expanded node id value.
            ExpandedNodeId expandedNodeId = value as ExpandedNodeId;

            if (expandedNodeId != null)
            {
                ShowValue(ref index, ref overwrite, expandedNodeId, 0);
                ShowValue(ref index, ref overwrite, expandedNodeId, 1);
                ShowValue(ref index, ref overwrite, expandedNodeId, 2);
                ShowValue(ref index, ref overwrite, expandedNodeId, 3);
                return;
            }            

            // show qualified name value.
            QualifiedName qualifiedName = value as QualifiedName;

            if (qualifiedName != null)
            {
                ShowValue(ref index, ref overwrite, qualifiedName, 0);
                ShowValue(ref index, ref overwrite, qualifiedName, 1);
                return;
            }

            // show qualified name value.
            LocalizedText localizedText = value as LocalizedText;

            if (localizedText != null)
            {
                ShowValue(ref index, ref overwrite, localizedText, 0);
                ShowValue(ref index, ref overwrite, localizedText, 1);
                return;
            }
            
            // show variant.
            Variant? variant = value as Variant?;

            if (variant != null)
            {
                ShowValue(ref index, ref overwrite, variant.Value.Value);
                return;
            }

            // show unknown types as strings.
            ShowValue(ref index, ref overwrite, String.Format("{0}", value));
        }
コード例 #34
0
ファイル: UIText.cs プロジェクト: egshels/Sources
 public void SetText(LocalizedText text)
 {
     InternalSetText(text, _textScale, _isLarge);
 }
コード例 #35
0
ファイル: ModelEncoder.cs プロジェクト: mregen/Industrial-IoT
 /// <inheritdoc />
 public void WriteLocalizedText(string fieldName, LocalizedText value)
 {
     _wrapped.WriteLocalizedText(fieldName, value);
 }
コード例 #36
0
        /// <summary>
        /// Translates the text provided.
        /// </summary>
        protected virtual LocalizedText Translate(IList<string> preferredLocales, LocalizedText defaultText, TranslationInfo info)
        {
            // check for trivial case.
            if (info == null || String.IsNullOrEmpty(info.Text))
            {
                return defaultText;
            }

            // check for exact match.
            if (preferredLocales != null && preferredLocales.Count > 0)
            {
                if (defaultText != null && preferredLocales[0] == defaultText.Locale)
                {
                    return defaultText;
                }

                if (preferredLocales[0] == info.Locale)
                {
                    return new LocalizedText(info);
                }
            }

            // use the text as the key.
            string key = info.Key;

            if (key == null)
            {
                key = info.Text;
            }

            // find the best translation.
            string translatedText = info.Text;
            CultureInfo culture = CultureInfo.InvariantCulture;

            lock (m_lock)
            {
                translatedText = FindBestTranslation(preferredLocales, key, out culture);

                // use the default if no translation available.
                if (translatedText == null)
                {
                    return defaultText;
                }

                // get a culture to use for formatting
                if (culture == null)
                {
                    if (info.Args != null && info.Args.Length > 0 && !String.IsNullOrEmpty(info.Locale))
                    {
                        try
                        {
                            culture = CultureInfo.GetCultureInfo(info.Locale);
                        }
                        catch
                        {
                            culture = CultureInfo.InvariantCulture;
                        }
                    }
                }
            }

            // format translated text.
            string formattedText = translatedText;

            if (info.Args != null && info.Args.Length > 0)
            {            
                try
                {
                    formattedText = String.Format(culture, translatedText, info.Args);
                }
                catch
                {
                    formattedText = translatedText;
                }
            }

            // construct translated localized text.
            Opc.Ua.LocalizedText finalText = new LocalizedText(culture.Name, formattedText);
            finalText.TranslationInfo = info;
            return finalText;
        }
コード例 #37
0
        public void CreateMainWindow(int MenuID)
        {
            string s = LocalizedText.Get("help.MENU_NUM");

            if (s == null)
            {
                return;
            }
            int num1 = int.Parse(s);

            if (MenuID < 0 || MenuID >= num1 || Object.op_Equality((Object)this.m_HelpMain, (Object)null))
            {
                return;
            }
            int       num2   = MenuID + 1;
            float     num3   = 0.0f;
            Transform child1 = this.m_HelpMain.get_transform().FindChild("header");

            if (Object.op_Inequality((Object)child1, (Object)null))
            {
                LText  component = (LText)((Component)child1.FindChild("Text")).GetComponent <LText>();
                string str       = LocalizedText.Get("help.MAIN_TITLE_" + (object)num2);
                if (string.IsNullOrEmpty(str) || str == "MAIN_TITLE_" + (object)num2)
                {
                    ((Component)child1).get_gameObject().SetActive(false);
                }
                else
                {
                    component.set_text(str);
                }
            }
            Transform image1 = this.m_HelpMain.get_transform().Find("page/template/contents/viewport/layout/contents_image");

            if (this.SetImageData(image1, "Image", "Helps/help_image_" + (object)num2))
            {
                LayoutElement component = (LayoutElement)((Component)image1).GetComponent <LayoutElement>();
                num3 += component.get_minHeight();
            }
            bool      flag   = false;
            Transform image2 = this.m_HelpMain.get_transform().Find("page/template/contents/viewport/layout/contents_image_small");

            if (flag | this.SetImageData(image2, "Image0", "Helps/help_image_" + (object)num2 + "_0") | this.SetImageData(image2, "Image1", "Helps/help_image_" + (object)num2 + "_1"))
            {
                ((Component)image2).get_gameObject().SetActive(true);
                LayoutElement component = (LayoutElement)((Component)image2).GetComponent <LayoutElement>();
                num3 += component.get_minHeight();
            }
            Transform child2 = this.m_HelpMain.get_transform().FindChild("page/template/contents/viewport/layout/contents_text");

            if (Object.op_Inequality((Object)child2, (Object)null))
            {
                Transform     child3     = child2.FindChild("Text");
                LText         component1 = (LText)((Component)child3).GetComponent <LText>();
                string        str1       = LocalizedText.Get("help.MAIN_TEXT_" + (object)num2);
                string        str2       = "help.MAIN_TEXT_" + (object)num2;
                LayoutElement component2 = (LayoutElement)((Component)child2).GetComponent <LayoutElement>();
                if (string.IsNullOrEmpty(str1) || str1 == "MAIN_TEXT_" + (object)num2)
                {
                    ((Component)child2).get_gameObject().SetActive(false);
                }
                else
                {
                    component1.set_text(str2);
                    ((Component)child2).get_gameObject().SetActive(true);
                    num3 += component2.get_preferredHeight();
                    HelpWindow.HELP_ID helpId           = (HelpWindow.HELP_ID)num2;
                    RectTransform      component3       = (RectTransform)((Component)child3).GetComponent <RectTransform>();
                    Vector2            anchoredPosition = component3.get_anchoredPosition();
                    switch (helpId)
                    {
                    case HelpWindow.HELP_ID.ACTION:
                        anchoredPosition.y = (__Null)150.0;
                        component3.set_anchoredPosition(anchoredPosition);
                        num3 -= component2.get_preferredHeight();
                        break;

                    case HelpWindow.HELP_ID.REACTION:
                    case HelpWindow.HELP_ID.SUPPORT:
                        anchoredPosition.y = (__Null)250.0;
                        component3.set_anchoredPosition(anchoredPosition);
                        num3 = component2.get_preferredHeight();
                        break;

                    case HelpWindow.HELP_ID.SHOP:
                        anchoredPosition.y = (__Null)200.0;
                        component3.set_anchoredPosition(anchoredPosition);
                        num3 -= component2.get_preferredHeight();
                        break;

                    default:
                        anchoredPosition.y = (__Null)0.0;
                        component3.set_anchoredPosition(anchoredPosition);
                        break;
                    }
                }
            }
            RectTransform child4            = this.m_HelpMain.get_transform().FindChild("page/template/contents/viewport/layout") as RectTransform;
            Vector2       anchoredPosition1 = child4.get_anchoredPosition();
            Vector2       sizeDelta         = child4.get_sizeDelta();

            sizeDelta.y = (__Null)(double)num3;
            child4.set_sizeDelta(sizeDelta);
            anchoredPosition1.y = (__Null)0.0;
            child4.set_anchoredPosition(anchoredPosition1);
            this.m_HelpMain.SetActive(true);
            if (Object.op_Implicit((Object)this.MiddleBackButton))
            {
                ((Component)this.MiddleBackButton).get_gameObject().SetActive(false);
            }
            ((Component)this.BackButton).get_gameObject().SetActive(true);
        }
コード例 #38
0
        private void Start()
        {
            if (Object.op_Inequality((Object)this.BackButton, (Object)null))
            {
                // ISSUE: method pointer
                ((UnityEvent)this.BackButton.get_onClick()).AddListener(new UnityAction((object)this, __methodptr(OnCloseMain)));
                ((Text)((Component)((Component)this.BackButton).get_transform().FindChild("Text")).GetComponent <LText>()).set_text(LocalizedText.Get("help.BACK_BUTTON"));
            }
            if (Object.op_Inequality((Object)this.MiddleBackButton, (Object)null))
            {
                // ISSUE: method pointer
                ((UnityEvent)this.MiddleBackButton.get_onClick()).AddListener(new UnityAction((object)this, __methodptr(OnBackList)));
                ((Text)((Component)((Component)this.MiddleBackButton).get_transform().FindChild("Text")).GetComponent <LText>()).set_text(LocalizedText.Get("help.BACK_BUTTON"));
            }
            string s1 = LocalizedText.Get("help.MENU_NUM");

            if (string.IsNullOrEmpty(s1))
            {
                return;
            }
            this.mHelpMenuButtons = new GameObject[int.Parse(s1)];
            if (!this.ReferenceFlowVariable)
            {
                return;
            }
            string s2 = FlowNode_Variable.Get(HelpWindow.VAR_NAME_MENU_ID);

            if (string.IsNullOrEmpty(s2))
            {
                return;
            }
            int result;

            if (int.TryParse(s2, out result))
            {
                this.CreateMainWindow(result - 1);
            }
            FlowNode_Variable.Set(HelpWindow.VAR_NAME_MENU_ID, string.Empty);
        }
コード例 #39
0
        private void RefreshData()
        {
            JobData jobData = this.mUnit.GetJobData(this.mJobIndex);

            DataSource.Bind <UnitData>(this.Unit, this.mUnit);
            for (int index = 0; index < this.Equipments.Count; ++index)
            {
                EquipData equip = jobData.Equips[index];
                DataSource.Bind <EquipData>(((Component)this.Equipments[index]).get_gameObject(), equip);
                bool flag = equip != null && (equip.IsValid() && equip.IsEquiped());
                ((Selectable)this.Equipments[index]).set_interactable(flag);
                ((Component)this.EquipmentRawImages[index]).get_gameObject().SetActive(flag);
                this.EquipmentCursors[index].SetActive(Object.op_Equality((Object)this.mSelectedEquipItem, (Object)((Component)this.Equipments[index]).get_gameObject()));
            }
            this.mEnhanceEquipData.equip       = (EquipData)null;
            this.mEnhanceEquipData.gainexp     = 0;
            this.mEnhanceEquipData.is_enhanced = false;
            for (int index = 0; index < this.mEnhanceParameters.Count; ++index)
            {
                this.mEnhanceParameters[index].SetActive(false);
            }
            ((Selectable)this.BtnEnhance).set_interactable(false);
            EquipData equipData = !Object.op_Inequality((Object)this.mSelectedEquipItem, (Object)null) ? (EquipData)null : DataSource.FindDataOfClass <EquipData>(this.mSelectedEquipItem, (EquipData)null);
            int       num1      = 0;
            int       num2      = 0;

            for (int index = 0; index < this.mMaterialItems.Count; ++index)
            {
                // ISSUE: object of a compiler-generated type is created
                // ISSUE: variable of a compiler-generated type
                EnhanceEquipDetailWindow.\u003CRefreshData\u003Ec__AnonStorey242 dataCAnonStorey242 = new EnhanceEquipDetailWindow.\u003CRefreshData\u003Ec__AnonStorey242();
                // ISSUE: reference to a compiler-generated field
                dataCAnonStorey242.item = this.mMaterialItems[index];
                // ISSUE: reference to a compiler-generated method
                EnhanceMaterial enhanceMaterial1 = this.mEnhanceMaterials.Find(new Predicate <EnhanceMaterial>(dataCAnonStorey242.\u003C\u003Em__26F));
                if (enhanceMaterial1 == null)
                {
                    EnhanceMaterial enhanceMaterial2 = new EnhanceMaterial();
                    // ISSUE: reference to a compiler-generated field
                    enhanceMaterial2.item = dataCAnonStorey242.item;
                    enhanceMaterial2.num  = 0;
                    this.mEnhanceMaterials.Add(enhanceMaterial2);
                    enhanceMaterial1 = enhanceMaterial2;
                }
                if (equipData != null)
                {
                    // ISSUE: reference to a compiler-generated field
                    num1 += (int)dataCAnonStorey242.item.Param.enhace_cost * equipData.GetEnhanceCostScale() / 100 * enhanceMaterial1.num;
                    // ISSUE: reference to a compiler-generated field
                    num2 += (int)dataCAnonStorey242.item.Param.enhace_point * enhanceMaterial1.num;
                }
            }
            bool flag1 = false;

            if (Object.op_Inequality((Object)this.EquipSelectParent, (Object)null))
            {
                DataSource.Bind <EnhanceEquipData>(this.EquipSelectParent, (EnhanceEquipData)null);
                this.EquipSelectParent.get_gameObject().SetActive(false);
            }
            if (Object.op_Inequality((Object)this.TxtComment, (Object)null))
            {
                ((Component)this.TxtComment).get_gameObject().SetActive(false);
            }
            if (Object.op_Inequality((Object)this.mSelectedEquipItem, (Object)null))
            {
                this.mEnhanceEquipData.equip   = equipData;
                this.mEnhanceEquipData.gainexp = num2;
                if (equipData != null)
                {
                    BuffEffect buffEffect = equipData.Skill.GetBuffEffect(SkillEffectTargets.Target);
                    if (buffEffect != null && buffEffect.targets != null)
                    {
                        for (int index = 0; index < buffEffect.targets.Count; ++index)
                        {
                            if (index >= this.mEnhanceParameters.Count)
                            {
                                this.ParamUpTemplate.SetActive(true);
                                GameObject gameObject = (GameObject)Object.Instantiate <GameObject>((M0)this.ParamUpTemplate);
                                gameObject.get_transform().SetParent(this.ParamUpLayoutParent, false);
                                this.mEnhanceParameters.Add(gameObject);
                                this.ParamUpTemplate.SetActive(false);
                            }
                            GameObject         enhanceParameter = this.mEnhanceParameters[index];
                            EquipItemParameter data             = DataSource.FindDataOfClass <EquipItemParameter>(enhanceParameter, (EquipItemParameter)null) ?? new EquipItemParameter();
                            data.equip       = equipData;
                            data.param_index = index;
                            DataSource.Bind <EquipItemParameter>(enhanceParameter, data);
                            enhanceParameter.SetActive(true);
                        }
                    }
                    flag1 = true;
                    if (equipData.Rank == equipData.GetRankCap())
                    {
                        if (Object.op_Inequality((Object)this.TxtComment, (Object)null))
                        {
                            this.TxtComment.set_text(LocalizedText.Get("sys.DIABLE_ENHANCE_RANKCAP_MESSAGE"));
                            ((Component)this.TxtComment).get_gameObject().SetActive(true);
                        }
                        flag1 = false;
                    }
                }
                if (Object.op_Inequality((Object)this.EquipSelectParent, (Object)null))
                {
                    DataSource.Bind <EnhanceEquipData>(this.EquipSelectParent, this.mEnhanceEquipData);
                    this.EquipSelectParent.get_gameObject().SetActive(true);
                }
            }
            else if (Object.op_Inequality((Object)this.TxtComment, (Object)null))
            {
                this.TxtComment.set_text(LocalizedText.Get("sys.ENHANCE_EQUIPMENT_MESSAGE"));
                ((Component)this.TxtComment).get_gameObject().SetActive(true);
            }
            this.mEnhanceEquipData.is_enhanced = flag1;
            if (Object.op_Inequality((Object)this.SelectedParent, (Object)null))
            {
                DataSource.Bind <EnhanceEquipData>(this.SelectedParent, this.mEnhanceEquipData);
                this.SelectedParent.get_gameObject().SetActive(flag1);
            }
            if (Object.op_Inequality((Object)this.TxtDisableEnhanceOnGauge, (Object)null))
            {
                ((Component)this.TxtDisableEnhanceOnGauge).get_gameObject().SetActive(!flag1);
            }
            if (Object.op_Inequality((Object)this.TxtCost, (Object)null))
            {
                this.TxtCost.set_text(num1.ToString());
            }
            if (Object.op_Inequality((Object)this.TxtJob, (Object)null))
            {
                this.TxtJob.set_text(jobData.Name);
            }
            if (flag1)
            {
                int num3 = equipData.CalcRankFromExp(equipData.Exp + num2);
                ((Selectable)this.BtnEnhance).set_interactable(equipData != null && equipData.Rank < num3);
            }
            if (Object.op_Inequality((Object)this.BtnAdd, (Object)null))
            {
                ((Selectable)this.BtnAdd).set_interactable(flag1 && Object.op_Inequality((Object)this.mSelectedMaterialItem, (Object)null));
            }
            if (Object.op_Inequality((Object)this.BtnSub, (Object)null))
            {
                ((Selectable)this.BtnSub).set_interactable(flag1 && Object.op_Inequality((Object)this.mSelectedMaterialItem, (Object)null));
            }
            this.mEnableEnhanceMaterials.Clear();
            for (int index = 0; index < this.mEnhanceMaterials.Count; ++index)
            {
                if (this.mEnhanceMaterials[index].item != null && this.mEnhanceMaterials[index].item.Num != 0)
                {
                    this.mEnableEnhanceMaterials.Add(this.mEnhanceMaterials[index]);
                }
            }
            this.SetData((object[])this.mEnableEnhanceMaterials.ToArray(), typeof(EnhanceMaterial));
            GameParameter.UpdateAll(((Component)this).get_gameObject());
        }
コード例 #40
0
        /// <summary>
        /// Creates an ReferenceType node with the specified node id.
        /// </summary>
        public NodeId CreateReferenceType(
            NodeId         parentId,
            NodeId         nodeId,
            QualifiedName  browseName,
            LocalizedText  displayName,
            LocalizedText  description,
            uint           writeMask,
            uint           userWriteMask,
            LocalizedText  inverseName,
            bool           isAbstract,
            bool           symmetric)
        {
            try
            {
                m_lock.Enter();
    
                // check for null node id.
                if (NodeId.IsNull(nodeId))
                {
                    nodeId = CreateUniqueNodeId();
                }

                // check if node id exists.
                if (m_nodes.Exists(nodeId))
                {
                    throw ServiceResultException.Create(StatusCodes.BadNodeIdExists, "NodeId '{0}' already exists.", nodeId);
                }

                // find parent.
                IReferenceType parent = GetManagerHandle(parentId) as IReferenceType;

                if (parent == null)
                {
                    throw ServiceResultException.Create(StatusCodes.BadParentNodeIdInvalid, "Parent node '{0}' does not exist or is not an ReferenceType.", parentId);
                }
                
                // validate reference.
                ValidateReference(parent, ReferenceTypeIds.HasSubtype, false, NodeClass.ReferenceType);

                // validate browse name.
                if (QualifiedName.IsNull(browseName))
                {
                    throw ServiceResultException.Create(StatusCodes.BadBrowseNameInvalid, "BrowseName must not be empty.");
                }

                // check that the browse name is unique.
                if (m_server.TypeTree.FindReferenceType(browseName) != null)
                {
                    throw ServiceResultException.Create(StatusCodes.BadBrowseNameInvalid, "A ReferenceType with the same BrowseName ({0}) already exists.", browseName);
                }

                // create node.
                ReferenceTypeNode node = new ReferenceTypeNode();

                node.NodeId          = nodeId;
                node.NodeClass       = NodeClass.ReferenceType;
                node.BrowseName      = browseName;
                node.DisplayName     = displayName;
                node.Description     = description;
                node.WriteMask       = writeMask;
                node.UserWriteMask   = userWriteMask;
                node.InverseName     = inverseName;
                node.IsAbstract      = isAbstract;
                node.Symmetric       = symmetric;

                if (node.DisplayName == null)
                {
                    node.DisplayName = new LocalizedText(browseName.Name);
                }

                // add reference from parent.
                AddReference(parent, ReferenceTypeIds.HasSubtype, false, node, true);
                
                // add node.
                AddNode(node);
                                
                // return the new node id.
                return node.NodeId;
            }
            finally
            {
                m_lock.Exit();
            } 
        }
コード例 #41
0
        /// <summary>
        /// Converts a local value to a remote value.
        /// </summary>
        /// <param name="srcValue">The local value.</param>
        /// <param name="srcType">The data type of the local value.</param>
        /// <param name="dstType">The data type of the remote value.</param>
        /// <returns>The remote value.</returns>
        private object ConvertLocalToRemote(object srcValue, BuiltInType srcType, BuiltInType dstType)
        {
            // must determine the type from the source if the containing array is a variant.
            if (srcType == BuiltInType.Variant)
            {
                TypeInfo typeInfo = TypeInfo.Construct(srcValue);
                srcType = typeInfo.BuiltInType;
            }

            // no conversion by default.
            object dstValue = srcValue;

            // apply different conversions depending on the data type.
            switch (dstType)
            {
                case BuiltInType.Guid:
                {
                    dstValue = new Uuid((string)srcValue);
                    break;
                }

                case BuiltInType.XmlElement:
                {
                    XmlDocument document = new XmlDocument();
                    document.InnerXml = (string)srcValue;
                    dstValue = document.DocumentElement;
                    break;
                }

                case BuiltInType.NodeId:
                {
                    dstValue = GetRemoteNodeId((string)srcValue);
                    break;
                }

                case BuiltInType.ExpandedNodeId:
                {
                    ExpandedNodeId nodeId = ExpandedNodeId.Parse((string)srcValue);
                    dstValue = GetRemoteExpandedNodeId(nodeId);
                    break;
                }

                case BuiltInType.QualifiedName:
                {
                    dstValue = GetRemoteBrowseName((string)srcValue);
                    break;
                }

                case BuiltInType.LocalizedText:
                {
                    dstValue = new LocalizedText((string)srcValue);
                    break;
                }

                case BuiltInType.StatusCode:
                {
                    dstValue = new StatusCode((uint)srcValue);
                    break;
                }

                case BuiltInType.ExtensionObject:
                {
                    BinaryDecoder decoder = new BinaryDecoder((byte[])srcValue, m_localMessageContext);
                    dstValue = decoder.ReadExtensionObject(null);
                    decoder.Close();
                    break;
                }

                default:
                {
                    if (dstType != srcType && dstType != BuiltInType.Variant && dstType != BuiltInType.Null)
                    {
                        throw ComUtils.CreateComException(ResultIds.E_BADTYPE);
                    }

                    break;
                }
            }

            // all done.
            return dstValue;
        }
コード例 #42
0
        /// <summary>
        /// Creates an DataType node in the address space.
        /// </summary>
        public NodeId CreateDataType(
            NodeId                            parentId,
            NodeId                            nodeId,
            QualifiedName                     browseName,
            LocalizedText                     displayName,
            LocalizedText                     description,
            uint                              writeMask,
            uint                              userWriteMask,
            bool                              isAbstract,
            IDictionary<QualifiedName,NodeId> encodings)
        {
             if (parentId == null)   throw new ArgumentNullException("parentId");
            if (browseName == null) throw new ArgumentNullException("browseName");

            try
            {
                m_lock.Enter();

                // check for null node id.
                if (NodeId.IsNull(nodeId))
                {
                    nodeId = CreateUniqueNodeId();
                }

                // check if node id exists.
                if (m_nodes.Exists(nodeId))
                {
                    throw ServiceResultException.Create(StatusCodes.BadNodeIdExists, "NodeId '{0}' already exists.", nodeId);
                }

                // find parent.
                IDataType parent = GetManagerHandle(parentId) as IDataType;

                if (parent == null)
                {
                    throw ServiceResultException.Create(StatusCodes.BadParentNodeIdInvalid, "Parent node '{0}' does not exist or is not an DataTypeNode.", parentId);
                }
                
                // validate reference.
                ValidateReference(parent, ReferenceTypeIds.HasSubtype, false, NodeClass.DataType);

                // validate browse name.
                if (QualifiedName.IsNull(browseName))
                {
                    throw ServiceResultException.Create(StatusCodes.BadBrowseNameInvalid, "BrowsName must not be empty.");
                }

                // create node.
                DataTypeNode node = new DataTypeNode();
                
                node.NodeId          = nodeId;
                node.NodeClass       = NodeClass.DataType;
                node.BrowseName      = browseName;
                node.DisplayName     = displayName;
                node.WriteMask     = writeMask;
                node.UserWriteMask = userWriteMask;
                node.Description     = description;
                node.IsAbstract      = isAbstract;

                // add reference from parent.
                AddReference(parent, ReferenceTypeIds.HasSubtype, false, node, true);

                // add node.
                AddNode(node);

                // add the encodings.
                if (encodings != null)
                {
                    List<QualifiedName> encodingNames = new List<QualifiedName>(encodings.Keys);

                    foreach (QualifiedName encodingName in encodingNames)
                    {
                        // assign a unique id to the encoding if none provided.
                        NodeId encodingId = encodings[encodingName];
                        
                        if (NodeId.IsNull(encodingId))
                        {
                            encodingId = CreateUniqueNodeId();
                        }

                        ObjectAttributes attributes = new ObjectAttributes();
                        attributes.SpecifiedAttributes = (uint)NodeAttributesMask.None;

                        // return the actual id.
                        encodings[encodingName] = CreateObject(
                            nodeId,
                            ReferenceTypeIds.HasEncoding,
                            encodingId,
                            encodingName,
                            attributes,
                            ObjectTypes.DataTypeEncodingType);
                    }
                }
                                
                // return the new node id.
                return node.NodeId;
            }
            finally
            {
                m_lock.Exit();
            } 
        }
コード例 #43
0
        protected override void Start()
        {
            base.Start();
            if (Object.op_Equality((Object)this.ItemTemplate, (Object)null))
            {
                return;
            }
            List <ItemData> items = MonoSingleton <GameManager> .Instance.Player.Items;

            this.mMaterialItems = new List <ItemData>(items.Count);
            for (int index = 0; index < items.Count; ++index)
            {
                if (items[index].CheckEquipEnhanceMaterial())
                {
                    this.mMaterialItems.Add(items[index]);
                }
            }
            this.mMaterialItems.Sort((Comparison <ItemData>)((src, dsc) =>
            {
                if (src.ItemType != dsc.ItemType)
                {
                    if (src.ItemType == EItemType.ExpUpEquip)
                    {
                        return(-1);
                    }
                    if (dsc.ItemType == EItemType.ExpUpEquip)
                    {
                        return(1);
                    }
                }
                return((int)dsc.Param.enhace_point - (int)src.Param.enhace_point);
            }));
            this.mUnit = MonoSingleton <GameManager> .Instance.Player.FindUnitDataByUniqueID((long)GlobalVars.SelectedUnitUniqueID);

            this.mJobIndex               = (int)GlobalVars.SelectedUnitJobIndex;
            this.mEnhanceEquipData       = new EnhanceEquipData();
            this.mEnhanceMaterials       = new List <EnhanceMaterial>(this.mMaterialItems.Count);
            this.mEnableEnhanceMaterials = new List <EnhanceMaterial>(this.mMaterialItems.Count);
            this.mEnhanceParameters      = new List <GameObject>(5);
            this.mSelectedEquipItem      = (GameObject)null;
            this.mSelectedMaterialItem   = (GameObject)null;
            if (Object.op_Inequality((Object)this.ItemTemplate, (Object)null) && this.ItemTemplate.get_activeInHierarchy())
            {
                this.ItemTemplate.get_transform().SetSiblingIndex(0);
                this.ItemTemplate.SetActive(false);
            }
            if (Object.op_Inequality((Object)this.BtnJob, (Object)null))
            {
                // ISSUE: method pointer
                ((UnityEvent)this.BtnJob.get_onClick()).AddListener(new UnityAction((object)this, __methodptr(OnJobChange)));
            }
            if (Object.op_Inequality((Object)this.BtnAdd, (Object)null))
            {
                // ISSUE: method pointer
                ((UnityEvent)this.BtnAdd.get_onClick()).AddListener(new UnityAction((object)this, __methodptr(OnAddMaterial)));
            }
            if (Object.op_Inequality((Object)this.BtnSub, (Object)null))
            {
                // ISSUE: method pointer
                ((UnityEvent)this.BtnSub.get_onClick()).AddListener(new UnityAction((object)this, __methodptr(OnSubMaterial)));
            }
            if (Object.op_Inequality((Object)this.BtnEnhance, (Object)null))
            {
                // ISSUE: method pointer
                ((UnityEvent)this.BtnEnhance.get_onClick()).AddListener(new UnityAction((object)this, __methodptr(OnEnhance)));
            }
            if (Object.op_Inequality((Object)this.TxtComment, (Object)null))
            {
                this.TxtComment.set_text(LocalizedText.Get("sys.ENHANCE_EQUIPMENT_MESSAGE"));
            }
            if (Object.op_Inequality((Object)this.TxtDisableEnhanceOnGauge, (Object)null))
            {
                this.TxtDisableEnhanceOnGauge.set_text(LocalizedText.Get("sys.DIABLE_ENHANCE_MESSAGE"));
            }
            for (int index = 0; index < this.Equipments.Count; ++index)
            {
                // ISSUE: object of a compiler-generated type is created
                // ISSUE: method pointer
                ((UnityEvent)this.Equipments[index].get_onClick()).AddListener(new UnityAction((object)new EnhanceEquipDetailWindow.\u003CStart\u003Ec__AnonStorey241()
                {
                    \u003C\u003Ef__this = this,
                    slot = index
                }, __methodptr(\u003C\u003Em__26E)));
            }
            this.RefreshData();
        }
コード例 #44
0
        private void OnAddMaterial()
        {
            if (Object.op_Equality((Object)this.mSelectedMaterialItem, (Object)null))
            {
                return;
            }
            EnhanceMaterial dataOfClass = DataSource.FindDataOfClass <EnhanceMaterial>(this.mSelectedMaterialItem, (EnhanceMaterial)null);

            if (dataOfClass != null)
            {
                if (!this.CheckEquipItemEnhance())
                {
                    UIUtility.NegativeSystemMessage(LocalizedText.Get("sys.FAILED_ENHANCE"), LocalizedText.Get("sys.DIABLE_ENHANCE_RANKCAP_MESSAGE"), (UIUtility.DialogResultEvent)null, (GameObject)null, false, -1);
                    return;
                }
                dataOfClass.num = Math.Min(++dataOfClass.num, dataOfClass.item.Num);
                DataSource.Bind <EnhanceMaterial>(this.mSelectedMaterialItem, dataOfClass);
            }
            this.RefreshData();
        }
コード例 #45
0
 public bool Equals(LocalizedText that)
 {
     return this == that;
 }