コード例 #1
0
        private void OnDeserialized(StreamingContext context)
        {
            if (Email == null)
                Email = new UIData<string>(Types.String);

            Validate();
        }
コード例 #2
0
    public UIData Open(UIID id)
    {
        UIData pData = null;

        count++;
        //单个页面的显示与否,和push无关
        if ((int)id <= _UIDatas.Length)
        {
            pData = _UIDatas [(int)id - 1];            //为了效率这里直接取得索引,但是不安全,必须保证id的顺序!!!
        }
        if (pData == null)
        {
            Debug.LogError("unregister ui found!!");
            return(null);
        }
        UIData newData = null;

        if (pData.bUnique)
        {
            bool foundUI = false;
            foreach (UIData data in _UIStack)
            {
                if (data.ID == pData.ID)                  //说明已经打开过
                {
                    data.count = count;                   //只要刷新数量就行
                    newData    = data;
                    foundUI    = true;
                    break;
                }
            }
            if (!foundUI)
            {
                //没有打开过则打开一个新的
                newData = MakeANewUI(pData, count);
            }
        }
        else
        {
            //打开一个新的
            newData = MakeANewUI(pData, count);
        }

        newData.UIObject.name = Enum.GetName(typeof(UIID), pData.ID) + "_" + count;       //计数和名字一致
        newData.UIObject.SetActive(true);
        newData.UIObject.transform.SetAsLastSibling();

        return(newData);
    }
コード例 #3
0
 public void HideOverViewByPage(string name)
 {
     if (m_UIDataMap.ContainsKey(name) && m_topPage != null && m_UIDataMap.ContainsKey(m_topPage))
     {
         UIData m_UIData = m_UIDataMap[name];
         if (m_UIData.viewStyle == UIViewStyle.OverView)
         {
             UIData m_UIDataPage = m_UIDataMap[m_topPage];
             if (m_UIData.gameObject.activeSelf)
             {
                 m_UIDataPage.hidenOverView.Add(m_UIData);
                 m_UIData.gameObject.SetActive(false);
             }
         }
     }
 }
コード例 #4
0
    private GameObject PushRepeatableLayer(string name, string fileName)
    {
        GameObject uiLoad = uiLoadDatas.GetGameObjectValue(fileName);

        if (uiLoad == null)
        {
            uiLoad = Resources.Load("UIPrefabs/" + fileName) as GameObject;
            uiLoadDatas.SetGameObjectValue(name, uiLoad);
        }
        GameObject ui     = GameObject.Instantiate(uiLoad, target) as GameObject;
        UIData     uiData = ui.AddComponent <UIData>();

        uiData.uiName = name;
        uiDatas.SetGameObjectValue(name, ui);
        return(ui);
    }
コード例 #5
0
 private void AutoDepthOverView(int baseDepth)
 {
     for (int i = 0; i < m_StackOverView.Count; i++)
     {
         UIData m_UIData = m_StackOverView[i];
         if (m_UIData.viewStyle == UIViewStyle.OverView)
         {
             UIPanel panel = m_UIData.gameObject.GetComponent <UIPanel>();
             if (panel == null)
             {
                 continue;
             }
             panel.depth = baseDepth + Config.OverViewLevelBaseDepth + (i) * Config.OverViewLevelDepth;
         }
     }
 }
コード例 #6
0
ファイル: Toast.cs プロジェクト: VietTho1989/Toast
 public override void onAddCallBack <T>(T data)
 {
     if (data is UIData)
     {
         UIData uiData = data as UIData;
         {
             uiData.toastData.allAddCallBack(this);
             uiData.toastMessageUI.allAddCallBack(this);
         }
         dirty = true;
         return;
     }
     if (data is ToastData)
     {
         ToastData toastData = data as ToastData;
         {
             ToastDataUpdate toastDataUpdate = this.GetComponent <ToastDataUpdate>();
             if (toastDataUpdate != null)
             {
                 toastDataUpdate.setData(toastData);
             }
             else
             {
                 Debug.LogError("toastDataUpdate null");
             }
         }
         dirty = true;
         return;
     }
     if (data is ToastMessageUI.UIData)
     {
         ToastMessageUI.UIData subUIData = data as ToastMessageUI.UIData;
         {
             if (toastMessageUI != null)
             {
                 toastMessageUI.setData(subUIData);
             }
             else
             {
                 Debug.LogError("toastMessageUI null");
             }
         }
         dirty = true;
         return;
     }
     Debug.LogError("Don't process: " + data + "; " + this);
 }
コード例 #7
0
        public override void OnInitialize()
        {
            string text =
                "- Main Developers\n" +
                "GoodPro712 - Current owner of Desiccation, main coder & manager\n" +
                "WeirdHat - Main stater, co-owner\n" +
                "Lemmy - Main content coder\n" +
                "\n" +
                "- Developers\n" +
                "Plex - Idea for the mod creation, multitool ideas & some sprites\n" +
                "Nobody - Stater, coder\n" +
                "Chem - Coder\n" +
                "Syringe - Stater\n" +
                "Daimgamer - Main spriter\n" +
                "Vectix - Main spriter\n" +
                "Zando - Main respriter\n" +
                "Rebmiami - Google docs helper, stater, coder\n" +
                "AnAvailableUsername - Stater\n" +
                "\n" +
                "- Main Helpers\n" +
                "Jopojelly - Huge help with code problems. Thx heaps!\n" +
                "Direwolf420 - Help with several code problems. Thx!\n" +
                "AbsoluteAquarian - Varius help with code problems. Thx alot!\n" +
                "\n" +
                "- Contributers\n" +
                "Darkpuppey - King blizzard resprite and some other spriting things\n" +
                "Spencer - Some random sprites\n" +
                "Orange - Werewolf Staff\n" +
                "Spectre - Vanilla shop additions\n" +
                "TraoX - Markoth, werewolf staff and gem reflecter sprites\n" +
                "Corinna - PlayerData libary code\n" +
                "Quartz - Some multitool sprites\n" +
                "Overhaul - Categorisation of config & teaching me how to method.Invoke\n" +
                "Darthmoth - Desiccation logo generator (without edits)\n" +
                "Jaserd - Edits on the Desiccation logo\n" +
                "Fargo - AI for the Hyper Scope\n" +
                "Mirsario - Unload errors from logo swapping. NPCAIStyle class. RemoveUnloadedTiles cmd\n" +
                "Itorius - Help with weighted inventory\n" +
                "Anegorami - Some ebic ideas" +
                "\n" +
                "- Patrons\n" +
                "Thank you so much to all of our patrons!\n" +
                $"Current patrons from v{ModContent.GetInstance<Desiccation>().Version} of Desiccation:\n" +
                "Waasephi - For donating $1 Thank You!!";

            UIData.UIInfoMessage_Show(text, 0);
        }
コード例 #8
0
    /// <summary>
    /// 关闭View
    /// </summary>
    /// <param name="name"></param>
    public void CloseView(string name, bool wakeUp = true)
    {
        if (m_UIDataMap.ContainsKey(name))
        {
            UIData m_UIData = m_UIDataMap[name];
            m_UIData.gameObject.SetActive(false);
            UIViewBase baseView = m_UIDataMap[name].gameObject.GetComponent <UIViewBase>();
            if (baseView != null)
            {
                baseView.OnClose();
            }
            switch (m_UIData.viewStyle)
            {
            case UIViewStyle.Page:
            case UIViewStyle.Window:
                m_StackPage.Remove(m_UIData);
                if (m_StackPage.Count > 0)
                {
                    if (wakeUp)
                    {
                        ActiveView(m_StackPage[m_StackPage.Count - 1], m_UIData.viewStyle == UIViewStyle.Page);
                    }
                    m_topPage     = m_StackPage[m_StackPage.Count - 1].name;
                    m_topViewData = m_StackPage[m_StackPage.Count - 1];
                }
                else
                {
                    m_topPage     = null;
                    m_topViewData = null;
                }
                break;

            case UIViewStyle.OverView:
                m_StackOverView.Remove(m_UIData);
                if (m_StackOverView.Count > 0)
                {
                    m_topOverView = m_StackOverView[m_StackOverView.Count - 1].name;
                }
                else
                {
                    m_topOverView = null;
                }
                break;
            }
            m_UIData.hidenOverView.Clear();
        }
    }
コード例 #9
0
        public static RectTransform FindTransformInPanel(string targetPanelName, string targetUINodePath)
        {
            UIData data = UIDataTable.Get(targetPanelName);

            if (data == null)
            {
                return(null);
            }
            //string panelName = string.Format("{0}(Clone)", targetPanelName);
            int uiId = UIMgr.S.FindTopPanel <IConvertible>();//UIMgr.S.uiRoot.panelRoot.Find(targetPanelName);

            if (uiId != data.uiID)
            {
                return(null);
            }

            AbstractPanel panel = UIMgr.S.FindPanel(data.uiID);

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

            Transform targetPanel = panel.transform;

            if (targetPanel == null)
            {
                //Log.w("# FindTransformInPanel Not Find Panel:" + panelName);
                return(null);
            }

            if (string.IsNullOrEmpty(targetUINodePath))
            {
                return(targetPanel as RectTransform);
            }

            RectTransform result = targetPanel.Find(targetUINodePath) as RectTransform;

            if (result == null || !result.gameObject.activeSelf)
            {
                //Log.w(string.Format("# FindTransformInPanel Not Find Node:{0}/{1}", panelName, targetUINodePath));
                return(null);
            }

            return(result);
        }
コード例 #10
0
    private void ShowNext()
    {
        // 다이얼로그를 리스트에서 첫번째 멤버를 가져옵니다.
        UIData next = _UIQueue[0];
        // 가져온 멤버의 다이얼로그 유형을 확인합니다.
        // 그래서 그 다이얼로그 유형에 맞는 다이얼로그 콘트롤러(DialogController)를 조회합니다.
        UIController controller = _UIMap[next.Type].GetComponent <UIController>();

        // 조회한 다이얼로그 콘트롤러를 현재 열린 팝업의 다이얼로그 콘트롤러로 지정합니다.
        _currentUI = controller;
        // 현재 보여주열 다이럴로그 데이터를 화면에 표시합니다.
        _currentUI.Build(next);
        // 다이얼로그를 화면에 보여주는 애니메이션을 시작합니다.
        _currentUI.Show(delegate { });
        // 다이얼로그 리스트에서 꺼내온 데이터를 제거합니다.
        _UIQueue.RemoveAt(0);
    }
コード例 #11
0
ファイル: MainUI.cs プロジェクト: pnf4665jds/BuildCube
    private void Start()
    {
        // 回到UI時開啟鼠標
        Cursor.lockState = CursorLockMode.None;
        Cursor.visible   = true;

        StartButton.onClick.AddListener(delegate
        {
            if (CubeDropdown.captionText.text != "--")
            {
                // 生成一個UIData來儲存所需資料
                UIData data     = new UIData();
                data.UserID     = IdField.text;
                data.TargetCube = CubeDropdown.captionText.text;
                // 存放在GameData讓其他場景存取
                GameData.instance.Data = data;
                // 初始化EventCenter
                GameEventCenter.EventCenterInit();
                SceneManager.LoadScene("GameScene");
            }
        });

        QuitButton.onClick.AddListener(delegate
        {
            Application.Quit();
        });

        CubeDropdown.onValueChanged.AddListener(delegate
        {
            if (CubeDropdown.captionText.text != "--")
            {
                LoadCube(CubeDropdown.captionText.text);
            }
            else
            {
                if (cube)
                {
                    Destroy(cube);
                }
                if (rotate != null)
                {
                    StopCoroutine(rotate);
                }
            }
        });
    }
コード例 #12
0
        internal override string CreateHtml()
        {
            var html = DynamicTextBuilder.Format(
                @"<div class='form-group'><label>{TextBox.Label}</label><input type='text' id='{TextBox.Id}' name='{TextBox.Name}' class='{TextBox.Class}' placeholder='{TextBox.Placeholder}' value='{TextBox.Value}' {TextBox.Attributes} /></div>",
                "TextBox",
                new {
                Id          = UIData.Id,
                Name        = UIData.Name,
                Label       = UIData.Label,
                Class       = UIData.Class,
                Placeholder = UIData.Placeholder,
                Value       = UIData.Value,
                Attributes  = UIData.CreateAttributesHtml()
            });

            return(html);
        }
コード例 #13
0
    private void Start()
    {
        sliderData = DataManager.Instance.getData(dataKeys);
        UIData uiData = GetComponent <UIData>();

        if (uiData)
        {
            uiData.changeCallback = UIStatus;
        }
        slider.value = (float)sliderData.GetNumberValue(dataValueKey);

        //sliderData.Bind(Change);
        //if(saveKey == "" && isPopSave)
        //{
        //    saveKey = dataValueKey;
        //}
    }
コード例 #14
0
    public UIData GetData(Type type)
    {
        UIData data = null;
        Type   dataType;

        if (_typeContainer.TryGetValue(type, out dataType))
        {
            if (_dataContainer.TryGetValue(dataType, out data))
            {
                return(data);
            }
        }

        Debug.LogError("UIData is Null : " + type);

        return(null);
    }
コード例 #15
0
        public BuildingUIData(SignalBus signalBus, MonoBehaviour monoBehaviour, Container.Cloud cloud, ref UIData uiData, Building office)
        {
            this.signalBus            = signalBus;
            this.cloud                = cloud;
            this.uiData               = uiData;
            this.proceduralUiElements = new ProceduralUiElements();
            this.building             = office as T;

            cloud.Materials.ForEach(material =>
            {
                if (material.name == "progressBar")
                {
                    projectButtonMaterial = material;
                }
            });
            this.monoBehaviour = monoBehaviour;
        }
コード例 #16
0
    public void ShowUI(UIData pathData, OnOpenUIDelegate delOpenUI = null, object parm = null)
    {
        Dictionary <string, BaseView> curDic = null;

        switch (pathData.uiType)
        {
        case UIData.UIType.TYPE_BASE:
            curDic = mDicBase;
            break;

        case UIData.UIType.TYPE_POP:
            curDic = mDicPop;
            break;

        case UIData.UIType.TYPE_DIALOG:
            curDic = mDicDialog;
            break;

        case UIData.UIType.TYPE_TIPS:

            break;

        case UIData.UIType.TYPE_TOP_BAR:
            curDic = mDicTop;
            break;
        }
        if (curDic == null)
        {
            return;
        }
        if (mDicCache.ContainsKey(pathData.name))
        {
            if (!curDic.ContainsKey(pathData.name))
            {
                curDic.Add(pathData.name, mDicCache[pathData.name]);
            }
            mDicCache.Remove(pathData.name);
        }
        if (curDic.ContainsKey(pathData.name))
        {
            DoShowUI(pathData, curDic[pathData.name].gameObject, delOpenUI, parm);
            return;
        }
        LoadUI(pathData, delOpenUI, parm);
    }
コード例 #17
0
        protected ICollection <LinkCategory> GetArchiveCategories(Blog blog)
        {
            var lcc = new List <LinkCategory>();

            LinkCategory storyCollection = UIData.Links(CategoryType.StoryCollection, blog, Url);

            if (storyCollection != null)
            {
                lcc.Add(storyCollection);
            }

            LinkCategory archiveMonth = UIData.ArchiveMonth(Url, blog);

            if (archiveMonth != null)
            {
                lcc.Add(archiveMonth);
            }

            /*
             * Uncomment this to test the Category Archive with post count
             * and comment to following block of code
             */

            //LinkCategory archiveCategories = UIData.ArchiveCategory(CurrentBlog.UrlFormats);
            //if (archiveCategories != null)
            //    lcc.Add(archiveCategories);


            LinkCategory postCollection = UIData.Links(CategoryType.PostCollection, blog, Url);

            if (postCollection != null)
            {
                lcc.Add(postCollection);
            }

            LinkCategory imageCollection = UIData.Links(CategoryType.ImageCollection, blog, Url);

            if (imageCollection != null)
            {
                lcc.Add(imageCollection);
            }

            lcc.AddRange(Repository.GetActiveCategories());
            return(lcc);
        }
コード例 #18
0
 public void ShowUIWithEnter(UIData pathData, OnOpenUIDelegate delOpen = null, object parm = null)
 {
     ShowUI(pathData, delegate(BaseView view, object param)
     {
         if (view != null)
         {
             view.OnEnter(parm, delegate
             {
                 {
                     if (delOpen != null)
                     {
                         delOpen(view, parm);
                     }
                 }
             });
         }
     }, parm);
 }
コード例 #19
0
        public void ModalOpen(string modal)
        {
            UIData uid = null;

            if (!mModals.TryGetValue(modal, out uid))
            {
                Debug.LogError("Modal not found: " + modal);
                return;
            }

            //wait for an update, this is to allow the ui game object to initialize properly
            mModalToOpen.Enqueue(uid);

            if (!mTaskActive)
            {
                StartCoroutine(DoTask());
            }
        }
コード例 #20
0
    private UIData GetUIData(string name)
    {
        UIData m_UIData = null;

        foreach (var item in m_UIDataRegisted)
        {
            if (item.name == name)
            {
                m_UIData = item;
                break;
            }
        }
        if (m_UIData.viewStyle == UIViewStyle.Window)
        {
            return(m_UIData.Clone());
        }
        return(m_UIData);
    }
コード例 #21
0
ファイル: ExcelRepository.cs プロジェクト: lanicon/WebAuto
        public DataBucket GetData(string filename)
        {
            var dataBucket = new DataBucket();

            if (!string.IsNullOrEmpty(filename))
            {
                foreach (var sheetName in Utility.GetExcelSheetNames(filename))
                {
                    if (IsDataTable(filename, sheetName))
                    {
                        var dataProvider = new ExcelStorage(typeof(UIDataRaw));
                        dataProvider.FileName    = filename;
                        dataProvider.StartRow    = 1;
                        dataProvider.StartColumn = 1;
                        dataProvider.SheetName   = sheetName;
                        var d1 = new UIData(dataProvider.SheetName, (UIDataRaw[])dataProvider.ExtractRecords());
                        if (!dataBucket.DataTables.ContainsKey(d1.DataName.ToLower()))
                        {
                            dataBucket.DataTables.Add(d1.DataName.ToLower(), d1);
                        }
                    }
                    else
                    {
                        var dataProvider = new ExcelStorage(typeof(UIMappingValueRaw));
                        dataProvider.SheetName   = sheetName;
                        dataProvider.FileName    = filename;
                        dataProvider.StartRow    = 2;
                        dataProvider.StartColumn = 1;
                        dataBucket.DataValues.Add(dataProvider.SheetName.ToLower(), new Dictionary <string, string>());
                        var d1 = (UIMappingValueRaw[])dataProvider.ExtractRecords();
                        foreach (var uiMappingValueRaw in d1)
                        {
                            string key = uiMappingValueRaw.Key.ToLower().TrimEnd();
                            if (!dataBucket.DataValues[dataProvider.SheetName.ToLower()].ContainsKey(key))
                            {
                                dataBucket.DataValues[dataProvider.SheetName.ToLower()].Add(key, uiMappingValueRaw.Value);
                            }
                        }
                    }
                }
            }
            return(dataBucket);
        }
コード例 #22
0
 public override void onRemoveCallBack <T>(T data, bool isHide)
 {
     if (data is UIData)
     {
         UIData uiData = data as UIData;
         // Child
         {
             uiData.state.allRemoveCallBack(this);
         }
         this.setDataNull(uiData);
         return;
     }
     // Child
     if (data is State)
     {
         return;
     }
     Logger.LogError("Don't process: " + data + "; " + this);
 }
コード例 #23
0
        /// <summary>
        /// Runs all the necessary methods to get info To main window
        /// </summary>
        /// <returns></returns>
        public async Task UISettings()
        {
            Countries = await UIData.GetCountriesListAsync(progress);

            total_countries_info.DataContext = Countries;

            gb_info_start.Visibility = Visibility.Visible;


            Rates = await UIData.GetRatesAsync();

            CommentsCountry = Task.Run(() => UIData.GetCommentsData()).Result;


            if (Countries.Count > 0 && Rates.Count > 0)
            {
                SaveData();
            }
        }
コード例 #24
0
ファイル: CuiGenerator.cs プロジェクト: rustmy/rustylife
        void IDrawUI(BasePlayer player, UIData data, CuiElementContainer additionalContainer)
        {
            DateTime now = DateTime.Now;

            if (!players.ContainsKey(player))
            {
                players.Add(player, new List <UIData>());
            }

            var funcs = players[player];

            for (int i = funcs.Count - 1; i >= 0; i--)
            {
                var func = funcs[i];
                if (func.plugin != data.plugin || func.funcName != data.funcName)
                {
                    continue;
                }
                players[player][i] = data;
                DrawUIWithoutCache(player, func, data, additionalContainer);
                return;
            }
            var json = functions[data.plugin][data.funcName][data.aspect];

            if (data.args.Length > 0)
            {
                json = HandleArgs(json, data.args);
            }
            players[player].Add(data);
            if (additionalContainer.Count > 0)
            {
                var elements = CuiHelper.FromJson(json);
                elements.AddRange(additionalContainer);
                json = CuiHelper.ToJson(elements);
            }
            CacheUI(player.userID, json);
            CuiHelper.AddUi(player, json);
            if (isDebug)
            {
                draw++;
                Puts(json);
            }
        }
コード例 #25
0
    void Awake()
    {
        mInstance = this;

        //setup data and deactivate object
        for (int i = 0; i < uis.Length; i++)
        {
            UIData       uid = uis[i];
            UIController ui  = uid.ui;
            if (ui != null)
            {
                ui.gameObject.SetActiveRecursively(false);
            }

            uid.type = (Modal)i;            //System.Enum.Parse(typeof(Modal), uid.name);
        }

        mHUD = GetComponentInChildren <HUDInterface>();
    }
コード例 #26
0
 public void HideAllOverViewByPage()
 {
     if (m_topPage != null && m_UIDataMap.ContainsKey(m_topPage))
     {
         foreach (var item in m_UIDataMap)
         {
             UIData m_UIData = item.Value;
             if (m_UIData.viewStyle == UIViewStyle.OverView)
             {
                 UIData m_UIDataPage = m_UIDataMap[m_topPage];
                 if (m_UIData.gameObject.activeSelf)
                 {
                     m_UIDataPage.hidenOverView.Add(m_UIData);
                     m_UIData.gameObject.SetActive(false);
                 }
             }
         }
     }
 }
コード例 #27
0
    private GameObject PushRepeatableLayer(string name, string fileName, UIChangeDelegate callback = null, bool isFreePop = true)
    {
        if (uiDatas.GetObjectValue(name) != null)
        {
            Debug.LogWarning("QIPAWORLD:重复添加UI--" + name);
            return(null);
        }

        GameObject uiLoad = LoadObjManager.Instance.GetLoadObj <GameObject>("UIPrefabs/" + fileName);

        GameObject ui     = GameObject.Instantiate <GameObject>(uiLoad, GameObject.Find("Canvas").transform);
        UIData     uiData = ui.AddComponent <UIData>();

        uiData.uiName         = name;
        uiData.changeCallback = callback;
        uiDatas.SetObjectValue(name, ui);
        uiNameList.Add(name);
        uiData.SetFreePop(isFreePop);
        return(ui);
    }
コード例 #28
0
        protected override void OnInstanceInit()
        {
            mModals      = new Dictionary <string, UIData>(uis.Length);
            mModalStack  = new Stack <UIData>(uis.Length);
            mModalToOpen = new Queue <UIData>(uis.Length);
            mTransitions = new TransitionBase[uis.Length];

            //setup data and deactivate object
            for (int i = 0; i < uis.Length; i++)
            {
                UIData     uid = uis[i];
                Controller ui  = uid.ui;
                if (ui != null)
                {
                    ui.gameObject.SetActive(false);
                }

                mModals.Add(uid.name, uid);
            }
        }
コード例 #29
0
 public override void onAddCallBack <T>(T data)
 {
     if (data is UIData)
     {
         UIData uiData = data as UIData;
         // Child
         {
             uiData.state.allAddCallBack(this);
         }
         dirty = true;
         return;
     }
     // Child
     if (data is State)
     {
         dirty = true;
         return;
     }
     Logger.LogError("Don't process: " + data + "; " + this);
 }
コード例 #30
0
ファイル: UIManager.cs プロジェクト: LYujia/UIFrameWork
    //向后打开UI,从list取,若没有则实例化
    public void OpenUI(UIData UIObject, object param = null)
    {
        BaseUI uiNewGoScript = null;
        int    uiListCount   = uiList.Count;

        if (uiListCount > 0)
        {
            uiNewGoScript = OpenUIBySort(UIObject, uiList[uiListCount - 1]);
        }
        else
        {
            uiNewGoScript = OpenUIBySort(UIObject);
        }
        if (uiNewGoScript != null)
        {
            uiNewGoScript.UpdateData(param);
        }

        uiList.Add(UIObject);//入栈
    }
コード例 #31
0
 protected override void OnUIElemntInit(UIData uiWindow)
 {
     switch (uiWindow.name)
     {
     case "KerbalScienceExchange":
         exchangeWindow = uiWindow;
         var content = exchangeWindow.gameObject.transform.Find("Content");
         var buttons = content.Find("ExchangeButtons");
         //InitInputField(exchangeWindow.)
         scienceField = InitInputField(content, "ScienceField", "0");
         scienceField.onValueChanged.AddListener(OnInputChange);
         InitTextField(content.Find("ConversionLabel"), "Label", settings.ratio.ToString());
         InitTextField(content.Find("TaxFeeLabel"), "Label", settings.tax.ToString());
         buyButton   = InitButton(buttons, "MoneyToScience", OnBuyScience);
         sellButton  = InitButton(buttons, "ScienceToMoney", OnSellScience);
         buyTooltip  = buyButton.GetComponent <Tooltip>();
         sellTooltip = sellButton.GetComponent <Tooltip>();
         break;
     }
 }
コード例 #32
0
ファイル: ExcelRepository.cs プロジェクト: ngocluu263/WebAuto
 public DataBucket GetData(string filename)
 {
     var dataBucket = new DataBucket();
     if (!string.IsNullOrEmpty(filename))
     {
         foreach (var sheetName in Utility.GetExcelSheetNames(filename))
         {
             if (IsDataTable(filename, sheetName))
             {
                 var dataProvider = new ExcelStorage(typeof(UIDataRaw));
                 dataProvider.FileName = filename;
                 dataProvider.StartRow = 1;
                 dataProvider.StartColumn = 1;
                 dataProvider.SheetName = sheetName;
                 var d1 = new UIData(dataProvider.SheetName, (UIDataRaw[])dataProvider.ExtractRecords());
                 if (!dataBucket.DataTables.ContainsKey(d1.DataName.ToLower()))
                 {
                     dataBucket.DataTables.Add(d1.DataName.ToLower(), d1);
                 }
             }
             else
             {
                 var dataProvider = new ExcelStorage(typeof(UIMappingValueRaw));
                 dataProvider.SheetName = sheetName;
                 dataProvider.FileName = filename;
                 dataProvider.StartRow = 2;
                 dataProvider.StartColumn = 1;
                 dataBucket.DataValues.Add(dataProvider.SheetName.ToLower(), new Dictionary<string, string>());
                 var d1 = (UIMappingValueRaw[])dataProvider.ExtractRecords();
                 foreach (var uiMappingValueRaw in d1)
                 {
                     string key = uiMappingValueRaw.Key.ToLower().TrimEnd();
                     if (!dataBucket.DataValues[dataProvider.SheetName.ToLower()].ContainsKey(key))
                         dataBucket.DataValues[dataProvider.SheetName.ToLower()].Add(key, uiMappingValueRaw.Value);
                 }
             }
         }
     }
     return dataBucket;
 }
コード例 #33
0
 public UserInterface(Stage stage)
 {
     this.stage = stage;
     uidata = new UIData();
     reverseRectangle = new Rectangle(500,10,0,10);
 }
コード例 #34
0
        public static UIData<bool> Validate(this UIData<bool> item)
        {
            if (item == null) { item = new UIData<bool>(false, Types.Boolean); }

            item.SubmittedValue = item.Value;
            item.IsValid = Constants.YES;
            item.Message = string.Empty;
            return item;
        }
コード例 #35
0
        public static UIData<int> Validate(this UIData<int> item, string requiredMessage = "")
        {
            if (item == null) { item = new UIData<int>(0, Types.Integer); }

            bool isGood = Constants.YES;
            string message = string.Empty;

            bool required = (requiredMessage.Length != 0);

            if (required && item.Value == 0)
            {
                isGood = Constants.NO;
                message = (requiredMessage.Length == 0 ? "Value required" : requiredMessage);
            }

            item.IsValid = isGood;
            item.Message = message;

            return item;
        }
コード例 #36
0
        private void OnDeserialized(StreamingContext context)
        {
            if (_email == null)
                _email = new UIData<string>(Types.String);
            if (_password == null)
                _password = new UIData<string>(Types.String);
            if (_token == null)
                _token = new UIData<string>(Types.String);
            if (_firstName == null)
                _firstName = new UIData<string>(Types.String);
            if (_lastName == null)
                _lastName = new UIData<string>(Types.String);

            Validate();
        }
コード例 #37
0
        private void InitProperties()
        {
            if (Email == null)
                Email = new UIData<string>(Types.String);
            if (Password == null)
                Password = new UIData<string>(Types.String);
            if (Token == null)
                Token = new UIData<string>(Types.String);
            if (FirstName == null)
                FirstName = new UIData<string>(Types.String);
            if (LastName == null)
                LastName = new UIData<string>(Types.String);
            if (UserAgent == null)
                UserAgent = new UIData<string>(Types.String);

            Validate();
        }
コード例 #38
0
        public static UIData<decimal> Validate(this UIData<decimal> item, DecimalFormat format = DecimalFormat.Plain, string requiredMessage = "")
        {
            if (item == null) { item = new UIData<decimal>(0, Types.Decimal); }

            bool isGood = Constants.YES;
            string message = string.Empty;

            bool required = (requiredMessage.Length != 0);

            if (required && item.Value == 0)
            {
                isGood = Constants.NO;
                message = (requiredMessage.Length == 0 ? "Value required" : requiredMessage);
            }

            item.IsValid = isGood;
            item.Message = message;

            return item;
        }
コード例 #39
0
 private static ValidatedData ValidateTitleCase(UIData<string> item, int maxLength, string requiredMessage)
 {
     ValidatedData result = ValidateGeneral(item, maxLength, requiredMessage);
     if (result.ContinueEvaluate)
     {
         System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
         System.Globalization.TextInfo textInfo = cultureInfo.TextInfo;
         result.NewValue = textInfo.ToTitleCase(item.Value);
     }
     return result;
 }
コード例 #40
0
 private static ValidatedData ValidateZipcode(UIData<string> item, string requiredMessage)
 {
     Int16 maxLength = 5;
     ValidatedData result = ValidateGeneral(item, maxLength, requiredMessage);
     if (result.ContinueEvaluate)
     {
         if (!RegexMatches(result.NewValue, StringFormat.ZipCode))
         {
             result.Message = "Invalid Zipcode";
             result.Warning = item.Value + " is invalid Zipcode";
             result.IsGood = Constants.NO;
         }
     }
     return result;
 }
コード例 #41
0
 private static ValidatedData ValidatePlain(UIData<string> item, int maxLength, string requiredMessage)
 {
     return ValidateGeneral(item, maxLength, requiredMessage);
 }
コード例 #42
0
        private static ValidatedData ValidateGeneral(UIData<string> item, int maxLength, string requiredMessage)
        {
            ValidatedData result = default(ValidatedData);
            result.NewValue = item.Value;
            result.Message = "";
            result.Warning = "";
            result.IsGood = true;
            result.ContinueEvaluate = true;

            bool isRequired = requiredMessage.Length > 0;

            if (item.Value.Length == 0 & isRequired)
            {
                result.Message = requiredMessage;
                result.Warning = "Value was empty";
                result.IsGood = false;
                result.ContinueEvaluate = false;
            }
            else
            {
                if (maxLength > 0 & item.Value.Length > maxLength)
                {
                    result.Message = "Max. " + maxLength + " characters";
                    result.Warning = "Value was " + item.Value.Length + " characters";
                    result.IsGood = false;
                    result.ContinueEvaluate = false;
                }
                else
                {
                    if (item.Value == string.Empty)
                    {
                        result.IsGood = true;
                        result.ContinueEvaluate = false;
                    }
                }
            }

            if (SQLInjection(item.Value))
            {
                result.Message = "Invalid string";
                result.Warning = "String contains sql injection characters.";
                result.IsGood = false;
                result.ContinueEvaluate = false;
            }

            return result;
        }
コード例 #43
0
 private static ValidatedData ValidateEmail(UIData<string> item, int maxLength, string requiredMessage)
 {
     ValidatedData result = ValidateGeneral(item, maxLength, requiredMessage);
     if (result.ContinueEvaluate)
     {
         if (!RegexMatches(result.NewValue.ToLower(), StringFormat.Email))
         {
             result.Message = "Invalid email";
             result.Warning = item.Value + " is invalid email";
             result.IsGood = Constants.NO;
         }
     }
     return result;
 }
コード例 #44
0
        private static ValidatedData ValidateDateTime(UIData<string> item, string requiredMessage)
        {
            string newValue = Regex.Replace(item.Value, "[^\x0d\x0a\x20-\x7e\t]", "");

            ValidatedData result = default(ValidatedData);
            result.NewValue = newValue;
            result.Message = "";
            result.Warning = "";
            result.IsGood = true;
            result.ContinueEvaluate = true;

            if (requiredMessage.Length == 0 && item.Value.Length == 0)
                return result;

            DateTime aDate;
            bool isADate = (DateTime.TryParse(newValue, out aDate));

            if (isADate)
            {
                result.NewValue = Convert.ToDateTime(newValue).ToString();
            }
            else
            {
                result.Message = "Invalid Date";
                result.Warning = item.Value + " is invalid Date";
                result.IsGood = Constants.NO;
            }

            return result;
        }
コード例 #45
0
        public static UIData<string> Validate(this UIData<string> item, StringFormat format = StringFormat.Plain, string requiredMessage = "", int maxLength = 0, bool trim = true, int roundingDecimals = 0)
        {
            if (item == null) { item = new UIData<string>("", Types.String); }

            item.Value = item.Value ?? "";

            bool isRequired = (requiredMessage.Length != 0);
            item.SubmittedValue = item.Value;

            if (item.TrueType == Types.Date)
                if (format != StringFormat.Date) { format = StringFormat.Date; }

            if (item.TrueType == Types.DateTime)
                if (format != StringFormat.DateTime) { format = StringFormat.DateTime; }

            if (format == StringFormat.TrueTypeDecimalPlain || format == StringFormat.TrueTypeDecimalMoney)
                item.TrueType = Types.Decimal;

            if (format == StringFormat.TrueTypeDouble)
                item.TrueType = Types.Double;

            if (format == StringFormat.TrueTypeInteger)
                item.TrueType = Types.Integer;

            switch (item.TrueType)
            {
                case Types.Integer:
                    item.Value = item.Value.Replace("$", "");
                    if (item.Value.Length == 0) { item.Value = "0"; }
                    if (IsNumeric(item.Value))
                    {
                        UIData<int> intData = new UIData<int>(Conversion.ToInt32(item.Value), Types.Integer);
                        intData.Validate(requiredMessage);
                        intData.CopyValuesTo(item);
                    }
                    else
                    {
                        item.IsValid = Constants.NO;
                        item.Message = (requiredMessage.Length == 0 ? "Invalid number" : requiredMessage);
                    }
                    break;
                case Types.Double:
                    item.Value = item.Value.Replace("$", "");
                    if (item.Value.Length == 0) { item.Value = "0"; }
                    if (IsNumeric(item.Value))
                    {
                        UIData<double> doubleData = new UIData<double>(Conversion.ToDouble(item.Value), Types.Double);
                        doubleData.Validate(requiredMessage);
                        doubleData.CopyValuesTo(item);
                    }
                    else
                    {
                        item.IsValid = Constants.NO;
                        item.Message = (requiredMessage.Length == 0 ? "Invalid number" : requiredMessage);
                    }
                    break;
                case Types.Decimal:
                    item.Value = item.Value.Replace("$", "");
                    if (item.Value.Length == 0) { item.Value = "0"; }
                    if (IsNumeric(item.Value))
                    {
                        UIData<decimal> decData = new UIData<decimal>(Conversion.ToDecimal(item.Value, roundingDecimals), Types.Decimal);
                        if (format == StringFormat.TrueTypeDecimalMoney)
                        {
                            decData.Validate(DecimalFormat.Money, requiredMessage);
                            decData.CopyValuesTo(item);
                            item.Value = decData.Value.ToString();
                        }
                        else
                        {
                            decData.Validate(DecimalFormat.Plain, requiredMessage);
                            decData.CopyValuesTo(item);
                        }
                    }
                    else
                    {
                        item.IsValid = Constants.NO;
                        item.Message = (requiredMessage.Length == 0 ? "Invalid number" : requiredMessage);
                    }
                    break;
                case Types.Boolean:
                    try
                    {
                        if (Convert.ToBoolean(item.Value) == true | Convert.ToBoolean(item.Value) == false)
                        {
                            UIData<bool> boolData = new UIData<bool>(Convert.ToBoolean(item.Value), Types.Decimal);
                            boolData.Validate();
                            boolData.CopyValuesTo(item);
                        }
                        else
                        {
                            item.IsValid = Constants.NO;
                            item.Message = (requiredMessage.Length == 0 ? "Invalid boolean value" : requiredMessage);
                        }
                    }
                    catch
                    {
                        item.IsValid = Constants.NO;
                        item.Message = (requiredMessage.Length == 0 ? "Invalid boolean value" : requiredMessage);
                    }
                    break;
                default:
                    if (trim) item.Value = item.Value.Trim();
                    ValidatedData result = new ValidatedData();

                    switch (format)
                    {
                        case StringFormat.Plain:
                            result = ValidatePlain(item, maxLength, requiredMessage);
                            break;
                        case StringFormat.TitleCase:
                            result = ValidateTitleCase(item, maxLength, requiredMessage);
                            break;
                        case StringFormat.Email:
                            result = ValidateEmail(item, maxLength, requiredMessage);
                            break;
                        case StringFormat.PhoneNumber:
                            result = ValidatePhoneNumber(item, requiredMessage);
                            break;
                        case StringFormat.SSN:
                            result = ValidateSSN(item, requiredMessage);
                            break;
                        case StringFormat.Date:
                            result = ValidateDate(item, requiredMessage);
                            break;
                        case StringFormat.DateTime:
                            result = ValidateDateTime(item, requiredMessage);
                            break;
                        case StringFormat.ZipCode:
                            result = ValidateZipcode(item, requiredMessage);
                            break;
                    }

                    item.IsValid = result.IsGood;
                    item.Message = result.Message;
                    item.Value = result.NewValue;
                    break;
            }

            return item;
        }