Exemple #1
0
 void Start()
 {
     if (!isSubview)
     {
         transform.name = menuName.ToString();
     }
     InstantiateMenuObject();
 }
Exemple #2
0
        public void OpenView(ViewName open, Transform parent = null)
        {
            if (isExistView(open))
            {
                IView target = _viewObjDic[open];
                target.Open();

                if (_curView != null)
                {
                    _curView.Close();
                }
                _curView = target;

                return;
            }

            if (!isExistViewName(open))
            {
                return;
            }

            string path = Utility.Path.GetViewPath(open.ToString());

            GameObject go;

            if (!AssetManager.ResourceLoadObj(path, out go, parent))
            {
                Debug.LogError(path + ": have not be found prefab: " + open.ToString());
                return;
            }
            go = Utility.View.InitUIObj(go);

            IView view = go.GetComponent <IView>();

            if (view == null)
            {
                Debug.LogError(open + ". The prefab not be found script inherit IView.");
                return;
            }

            RegisterView(view.Name, view);

            if (_curView != null)
            {
                _curView.Close();
            }

            view.Open();
            _curView = view;
        }
        public FunctionListViewModel(ViewName viewName, int order, params string[] functions)
        {
            ViewName       = viewName;
            FunctionHeader = ViewName.ToString();
            RowCount       = functions.Length;
            RowIndex       = order;

            FunctionPadCollection = new ObservableCollection <InputButtonViewModel>();
            int i = 0;

            foreach (string function in functions)
            {
                FunctionPadCollection.Add(new InputButtonViewModel(i++, 0, new MathButton(function, "type", string.Format("helper : {0}", function))));
            }
        }
Exemple #4
0
    void PopulateButtons()
    {
        if (!hasDynamicMenuButtonTitles)
        {
            foreach (ViewName subMenuItem in subMenuItems)
            {
                subMenuItemNames.Add(subMenuItem.ToString());
            }
        }

        if (leftButtonName != ViewName.None)
        {
            string     menuButtonName = leftButtonName.ToString();
            MenuButton leftMenuButton = leftButton.GetComponent <MenuButton>();
            leftMenuButton.InitializeButtonProperties(menuButtonName, menuButtonName, menuButtonName);
            leftButton.SetActive(true);
        }
        else
        {
            leftButton.SetActive(false);
        }

        if (rightButtonName != ViewName.None)
        {
            string     menuButtonName  = rightButtonName.ToString();
            MenuButton rightMenuButton = rightButton.GetComponent <MenuButton>();
            rightMenuButton.InitializeButtonProperties(menuButtonName, menuButtonName, menuButtonName);
            rightButton.SetActive(true);
        }
        else
        {
            rightButton.SetActive(false);
        }

        for (int i = 0; i < subMenuItemNames.Count; i++)
        {
            // Create new instances of our prefab until we've created as many as we specified
            string     menuButtonName = subMenuItemNames[i];
            GameObject newMenuButton  = (GameObject)Instantiate(MenuButtonPF, transform);
            MenuButton menuButton     = newMenuButton.GetComponent <MenuButton>();
            menuButton.InitializeButtonProperties(menuButtonName, menuButtonName, menuButtonName);
            newMenuButton.transform.parent = transform.GetComponentInChildren <GridLayoutGroup>().transform;
            menuButton.menuPanelObject     = gameObject;
        }
    }
Exemple #5
0
 private void Repopulate()
 {
     if (_inRepopulate)
     {
         return;
     }
     try
     {
         _inRepopulate = true;
         if (!Equals(SelectedGroup, toolStripComboGroup.SelectedItem))
         {
             listView1.Items.Clear();
         }
         toolStripComboGroup.Items.Clear();
         imageList1.Images.Clear();
         var newItems  = new List <ListViewItem>();
         var newGroups = new List <ListViewGroup>();
         if (null != ViewContext)
         {
             imageList1.Images.AddRange(ViewContext.GetImageList());
             toolStripComboGroup.Items.AddRange(ViewContext.ViewGroups.ToArray());
             IEnumerable <ViewGroup> groups;
             if (null != SelectedGroup)
             {
                 groups         = new[] { SelectedGroup };
                 listView1.View = View.List;
             }
             else
             {
                 groups         = ViewContext.ViewGroups;
                 listView1.View = View.SmallIcon;
             }
             foreach (var group in groups)
             {
                 var listViewGroup = new ListViewGroup(group.Id.Name, group.Label)
                 {
                     Tag = group
                 };
                 newGroups.Add(listViewGroup);
                 foreach (var viewSpec in ViewContext.GetViewSpecList(group.Id).ViewSpecs)
                 {
                     bool validRowSource = null != ViewContext.GetViewInfo(new ViewName(group.Id, viewSpec.Name));
                     if (FilterRowSources && !validRowSource)
                     {
                         continue;
                     }
                     var viewName = new ViewName(group.Id, viewSpec.Name);
                     var item     = new ListViewItem(viewSpec.Name, ViewContext.GetImageIndex(viewSpec))
                     {
                         Name    = viewName.ToString(),
                         Group   = listViewGroup,
                         Tag     = viewName,
                         Checked = _checkedItems.Contains(viewName),
                     };
                     if (!validRowSource && GrayDisabledRowSources)
                     {
                         item.ForeColor = SystemColors.GrayText;
                     }
                     newItems.Add(item);
                 }
             }
             toolStripComboGroup.SelectedItem = SelectedGroup;
         }
         ReplaceItems(listView1, newGroups, newItems);
     }
     finally
     {
         _inRepopulate = false;
     }
 }
 private void Repopulate()
 {
     if (_inRepopulate)
     {
         return;
     }
     try
     {
         _inRepopulate = true;
         if (!Equals(SelectedGroup, toolStripComboGroup.SelectedItem))
         {
             listView1.Items.Clear();
         }
         toolStripComboGroup.Items.Clear();
         imageList1.Images.Clear();
         var newItems = new List<ListViewItem>();
         var newGroups = new List<ListViewGroup>();
         if (null != ViewContext)
         {
             imageList1.Images.AddRange(ViewContext.GetImageList());
             toolStripComboGroup.Items.AddRange(ViewContext.ViewGroups.ToArray());
             IEnumerable<ViewGroup> groups;
             if (null != SelectedGroup)
             {
                 groups = new[] {SelectedGroup};
                 listView1.View = View.List;
             }
             else
             {
                 groups = ViewContext.ViewGroups;
                 listView1.View = View.SmallIcon;
             }
             foreach (var group in groups)
             {
                 var listViewGroup = new ListViewGroup(group.Id.Name, group.Label) {Tag = group};
                 newGroups.Add(listViewGroup);
                 foreach (var viewSpec in ViewContext.GetViewSpecList(group.Id).ViewSpecs)
                 {
                     bool validRowSource = null != ViewContext.GetViewInfo(new ViewName(group.Id, viewSpec.Name));
                     if (FilterRowSources && !validRowSource)
                     {
                         continue;
                     }
                     var viewName = new ViewName(group.Id, viewSpec.Name);
                     var item = new ListViewItem(viewSpec.Name, ViewContext.GetImageIndex(viewSpec))
                     {
                         Name = viewName.ToString(),
                         Group= listViewGroup,
                         Tag = viewName,
                         Checked = _checkedItems.Contains(viewName),
                     };
                     if (!validRowSource && GrayDisabledRowSources)
                     {
                         item.ForeColor = SystemColors.GrayText;
                     }
                     newItems.Add(item);
                 }
             }
             toolStripComboGroup.SelectedItem = SelectedGroup;
         }
         ReplaceItems(listView1, newGroups, newItems);
     }
     finally
     {
         _inRepopulate = false;
     }
 }