Exemplo n.º 1
0
 public void AddChild(FrameworkElement el)
 {
     if (Children.OfType <FrameworkElement>().Contains(el))
     {
         Children.Remove(el);
         Items?.Remove((PriceTagItem)el.DataContext);
     }
     Children.Add(el);
     Items?.Add((PriceTagItem)el.DataContext);
 }
Exemplo n.º 2
0
 private void OnInsertItem(object sender, GlossListEventArgs glea)
 {
     // Adds the GlossListBoxItem contained within the GlossListEventArgs object
     Items.Add(glea.GlossListBoxItem);
 }
Exemplo n.º 3
0
 public void AddProduct(Item item)
 {
     item.Order = this;
     Items.Add(item);
 }
Exemplo n.º 4
0
 public void Log <TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter)
 => Items.Add(new { logLevel, eventId, state, exception });
Exemplo n.º 5
0
        public WindowsSelector(AutomationElement element, WindowsSelector anchor, bool doEnum)
        {
            var sw = new System.Diagnostics.Stopwatch();

            sw.Start();
            Log.Selector(string.Format("windowsselector::begin {0:mm\\:ss\\.fff}", sw.Elapsed));

            AutomationElement root        = null;
            AutomationElement baseElement = null;
            var pathToRoot = new List <AutomationElement>();

            while (element != null)
            {
                // Break on circular relationship (should not happen?)
                //if (pathToRoot.Contains(element) || element.Equals(_rootElement)) { break; }
                // if (pathToRoot.Contains(element)) { break; }
                try
                {
                    if (element.Parent != null)
                    {
                        pathToRoot.Add(element);
                    }
                    if (element.Parent == null)
                    {
                        root = element;
                    }
                }
                catch (Exception)
                {
                    root = element;
                }
                try
                {
                    //element = _treeWalker.GetParent(element);
                    element = element.Parent;
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "");
                    return;
                }
            }
            Log.Selector(string.Format("windowsselector::create pathToRoot::end {0:mm\\:ss\\.fff}", sw.Elapsed));
            pathToRoot.Reverse();
            if (anchor != null)
            {
                bool SearchDescendants = false;
                var  p = anchor.First().Properties.Where(x => x.Name == "SearchDescendants").FirstOrDefault();
                if (p.Value != null && p.Value == "true")
                {
                    SearchDescendants = true;
                }
                if (SearchDescendants)
                {
                    var a   = anchor.Last();
                    var idx = -1;
                    for (var i = 0; i < pathToRoot.Count(); i++)
                    {
                        if (WindowsSelectorItem.Match(a, pathToRoot[i]))
                        {
                            idx = i;
                            // break;
                        }
                    }
                    pathToRoot.RemoveRange(0, idx);
                }
                else
                {
                    var anchorlist = anchor.Where(x => x.Enabled && x.Selector == null).ToList();
                    for (var i = 0; i < anchorlist.Count(); i++)
                    {
                        if (WindowsSelectorItem.Match(anchorlist[i], pathToRoot[0]))
                        //if (((WindowsSelectorItem)anchorlist[i]).Match(pathToRoot[0]))
                        {
                            pathToRoot.Remove(pathToRoot[0]);
                        }
                        else
                        {
                            Log.Selector("Element does not match the anchor path");
                            return;
                        }
                    }
                }
            }
            WindowsSelectorItem item;

            if (PluginConfig.traverse_selector_both_ways)
            {
                Log.Selector(string.Format("windowsselector::create traverse_selector_both_ways::begin {0:mm\\:ss\\.fff}", sw.Elapsed));
                var temppathToRoot = new List <AutomationElement>();
                var newpathToRoot  = new List <AutomationElement>();
                foreach (var e in pathToRoot)
                {
                    temppathToRoot.Add(e);
                }
                Log.Selector(string.Format("windowsselector::traverse back to element from root::begin {0:mm\\:ss\\.fff}", sw.Elapsed));
                using (var automation = AutomationUtil.getAutomation())
                {
                    bool isDesktop           = true;
                    AutomationElement parent = null;
                    if (anchor != null)
                    {
                        parent = temppathToRoot[0].Parent; isDesktop = false;
                    }
                    else
                    {
                        parent = automation.GetDesktop();
                    }
                    int count = temppathToRoot.Count;
                    while (temppathToRoot.Count > 0)
                    {
                        count--;
                        var i = temppathToRoot.First();
                        temppathToRoot.Remove(i);
                        item = new WindowsSelectorItem(i, false);
                        if (parent != null)
                        {
                            var m = item.matches(root, count, parent, 2, isDesktop, false);
                            if (m.Length > 0)
                            {
                                newpathToRoot.Add(i);
                                parent    = i;
                                isDesktop = false;
                            }
                            if (m.Length == 0 && Config.local.log_selector)
                            {
                                //var message = "needed to find " + Environment.NewLine + item.ToString() + Environment.NewLine + "but found only: " + Environment.NewLine;
                                //var children = parent.FindAllChildren();
                                //foreach (var c in children)
                                //{
                                //    try
                                //    {
                                //        message += new UIElement(c).ToString() + Environment.NewLine;
                                //    }
                                //    catch (Exception)
                                //    {
                                //    }
                                //}
                                //Log.Debug(message);
                            }
                        }
                        else
                        {
                            var b = true;
                        }
                    }
                }
                if (newpathToRoot.Count != pathToRoot.Count)
                {
                    Log.Information("Selector had " + pathToRoot.Count + " items to root, but traversing children only matched " + newpathToRoot.Count);
                    pathToRoot = newpathToRoot;
                }
                Log.Selector(string.Format("windowsselector::create traverse_selector_both_ways::end {0:mm\\:ss\\.fff}", sw.Elapsed));
            }
            if (pathToRoot.Count == 0)
            {
                Log.Error("Element has not parent, or is same as annchor");
                return;
            }
            baseElement = pathToRoot.First();
            element     = pathToRoot.Last();
            Clear();
            Log.Selector(string.Format("windowsselector::remove anchor if needed::end {0:mm\\:ss\\.fff}", sw.Elapsed));
            if (anchor == null)
            {
                Log.Selector(string.Format("windowsselector::create root element::begin {0:mm\\:ss\\.fff}", sw.Elapsed));
                item         = new WindowsSelectorItem(baseElement, true);
                item.Enabled = true;
                //item.canDisable = false;
                Items.Add(item);
                Log.Selector(string.Format("windowsselector::create root element::end {0:mm\\:ss\\.fff}", sw.Elapsed));
            }

            if (PluginConfig.search_descendants)
            {
                Log.Selector(string.Format("windowsselector::search_descendants::begin {0:mm\\:ss\\.fff}", sw.Elapsed));
                if (anchor == null)
                {
                    // Add window, we NEED to search from a window
                    item = new WindowsSelectorItem(pathToRoot[0], false, -1);
                    if (doEnum)
                    {
                        item.EnumNeededProperties(pathToRoot[pathToRoot.Count - 1], pathToRoot[pathToRoot.Count - 1].Parent);
                    }
                    item.canDisable = false;
                    Items.Add(item);


                    var FrameworkId = item.Properties.Where(x => x.Name == "FrameworkId").FirstOrDefault();
                    if (FrameworkId != null && (FrameworkId.Value == "XAML" || FrameworkId.Value == "WinForm"))
                    {
                        var itemname = item.Properties.Where(x => x.Name == "Name").FirstOrDefault();
                        if (itemname != null)
                        {
                            itemname.Enabled = false;
                        }
                    }
                }
                if (pathToRoot.Count > 2)
                {
                    item = new WindowsSelectorItem(pathToRoot[pathToRoot.Count - 2], false, -1);
                    if (doEnum)
                    {
                        item.EnumNeededProperties(pathToRoot[pathToRoot.Count - 2], pathToRoot[pathToRoot.Count - 2].Parent);
                    }
                    Items.Add(item);
                }
                if (pathToRoot.Count > 1)
                {
                    int IndexInParent = -1;
                    if (pathToRoot[pathToRoot.Count - 1].Parent != null)
                    {
                        var c = pathToRoot[pathToRoot.Count - 1].Parent.FindAllChildren();
                        for (var x = 0; x < c.Count(); x++)
                        {
                            if (pathToRoot[pathToRoot.Count - 1].Equals(c[x]))
                            {
                                IndexInParent = x;
                            }
                        }
                    }
                    item = new WindowsSelectorItem(pathToRoot[pathToRoot.Count - 1], false, IndexInParent);
                    if (doEnum)
                    {
                        item.EnumNeededProperties(pathToRoot[pathToRoot.Count - 1], pathToRoot[pathToRoot.Count - 1].Parent);
                    }
                    Items.Add(item);
                }
                Log.Selector(string.Format("windowsselector::search_descendants::end {0:mm\\:ss\\.fff}", sw.Elapsed));
            }
            else
            {
                bool isStartmenu = false;
                for (var i = 0; i < pathToRoot.Count(); i++)
                {
                    Log.Selector(string.Format("windowsselector::search_descendants::loop element " + i + ":begin {0:mm\\:ss\\.fff}", sw.Elapsed));
                    var o             = pathToRoot[i];
                    int IndexInParent = -1;
                    if (o.Parent != null && i > 0)
                    {
                        var c = o.Parent.FindAllChildren();
                        for (var x = 0; x < c.Count(); x++)
                        {
                            if (o.Equals(c[x]))
                            {
                                IndexInParent = x;
                            }
                        }
                    }

                    item = new WindowsSelectorItem(o, false, IndexInParent);
                    var _IndexInParent = item.Properties.Where(x => x.Name == "IndexInParent").FirstOrDefault();
                    if (_IndexInParent != null)
                    {
                        _IndexInParent.Enabled = false;
                    }
                    if (i == 0 || i == (pathToRoot.Count() - 1))
                    {
                        item.canDisable = false;
                    }
                    foreach (var p in item.Properties)
                    {
                        int idx = p.Value.IndexOf(".");
                        if (p.Name == "ClassName" && idx > -1)
                        {
                            var FrameworkId = item.Properties.Where(x => x.Name == "FrameworkId").FirstOrDefault();
                            //if (FrameworkId!=null && (FrameworkId.Value == "XAML" || FrameworkId.Value == "WinForm") && _IndexInParent != null)
                            //{
                            //    item.Properties.ForEach(x => x.Enabled = false);
                            //    _IndexInParent.Enabled = true;
                            //    p.Enabled = true;
                            //}
                            int idx2 = p.Value.IndexOf(".", idx + 1);
                            // if (idx2 > idx) p.Value = p.Value.Substring(0, idx2 + 1) + "*";
                            if (idx2 > idx && item.Properties.Count > 1)
                            {
                                p.Enabled = false;
                            }
                        }
                        //if (p.Name == "ClassName" && p.Value.StartsWith("WindowsForms10")) p.Value = "WindowsForms10*";
                        if (p.Name == "ClassName" && p.Value.ToLower() == "shelldll_defview")
                        {
                            item.Enabled = false;
                        }
                        if (p.Name == "ClassName" && (p.Value.ToLower() == "dv2vontrolhost" || p.Value.ToLower() == "desktopprogramsmfu"))
                        {
                            isStartmenu = true;
                        }
                        //if (p.Name == "ClassName" && p.Value == "#32770")
                        //{
                        //    item.Enabled = false;
                        //}
                        if (p.Name == "ControlType" && p.Value == "ListItem" && isStartmenu)
                        {
                            p.Enabled = false;
                        }
                    }
                    var hassyslistview32 = item.Properties.Where(p => p.Name == "ClassName" && p.Value.ToLower() == "syslistview32").ToList();
                    if (hassyslistview32.Count > 0)
                    {
                        var hasControlType = item.Properties.Where(p => p.Name == "ControlType").ToList();
                        if (hasControlType.Count > 0)
                        {
                            hasControlType[0].Enabled = false;
                        }
                    }

                    if (doEnum)
                    {
                        item.EnumNeededProperties(o, o.Parent);
                    }
                    Items.Add(item);
                    Log.Selector(string.Format("windowsselector::search_descendants::loop element " + i + ":end {0:mm\\:ss\\.fff}", sw.Elapsed));
                }
            }
            pathToRoot.Reverse();
            if (anchor != null)
            {
                var p = Items[0].Properties.Where(x => x.Name == "SearchDescendants").FirstOrDefault();
                if (p == null)
                {
                    Items[0].Properties.Add(new SelectorItemProperty("SearchDescendants", PluginConfig.search_descendants.ToString()));
                }
            }
            Log.Selector(string.Format("windowsselector::end {0:mm\\:ss\\.fff}", sw.Elapsed));
            OnPropertyChanged(new System.ComponentModel.PropertyChangedEventArgs("Count"));
            OnPropertyChanged(new System.ComponentModel.PropertyChangedEventArgs("Item[]"));
            OnCollectionChanged(new System.Collections.Specialized.NotifyCollectionChangedEventArgs(System.Collections.Specialized.NotifyCollectionChangedAction.Reset));
        }
Exemplo n.º 6
0
 public ConfigRoot AddItem(string desc, BaseItemConfig item)
 {
     Items.Add(desc, item);
     return(this);
 }
Exemplo n.º 7
0
 protected void AddItem(string stText, TObject item)
 {
     Items.Add(new ListPair <TObject>(item, stText));
 }
Exemplo n.º 8
0
 /// <summary>
 /// Adds an item to the array.
 /// </summary>
 /// <param name="item"></param>
 public void AddItem(string item)
 {
     Items.Add(item);
 }
Exemplo n.º 9
0
        /// <summary>
        /// 搜索框内容改变事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ComboBoxTextBoxTextChangedEventHandler(object sender, TextChangedEventArgs e)
        {
            if (dicNameKeys == null)
            {
                return;
            }
            string value = txt.Text;

            if (value == "")
            {
                IsDropDownOpen = false;
                return;
            }
            Items.Clear();
            int index = -1;

            foreach (var i in dicNameKeys)
            {
                index++;
                if (IsMatch(value, i.Value))
                {
                    ComboBoxItem cbbItem = new ComboBoxItem()
                    {
                        Content = i.Key, Tag = index
                    };
                    cbbItem.PreviewMouseLeftButtonUp += (p1, p2) =>
                    {
                        Select(cbbItem, new SelectEventArgs(p1 as ComboBoxItem));
                        IsDropDownOpen = false;
                        Text           = "";
                    };
                    Items.Add(cbbItem);
                    IsDropDownOpen = true;
                }
            }


            //foreach (var i in musicDatas)
            //{
            //    index++;

            //    if (IsInfoMatch(value, i))
            //    {
            //        ComboBoxItem cbbItem = new ComboBoxItem() { Content = i.MusicName, Tag = index };
            //        cbbItem.PreviewMouseLeftButtonUp += (p1, p2) =>
            //        {
            //            PlayNew((int)cbbItem.Tag, false);
            //            IsDropDownOpen = false;
            //            Text = "";
            //        };

            //        Items.Add(cbbItem);
            //        DropDownOpened += (p1, p2) =>
            //        {
            //            txt.SelectionLength = 0;
            //            txt.SelectionStart = (txt.Text.Length);
            //        };
            //        IsDropDownOpen = true;

            //    }
            //}
        }
Exemplo n.º 10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SuckerFishMenuHelper"/> class.
        /// </summary>
        /// <param name="projectId">The project id.</param>
        public SuckerFishMenuHelper(int projectId)
        {
            //Setup menu...
            Items.Add(new SuckerMenuItem("~/Default", Resources.SharedResources.Home, this));



            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                Items.Add(new SuckerMenuItem("~/Issues/MyIssues", Resources.SharedResources.MyIssues, this));
            }

            if (projectId > Globals.NEW_ID)
            {
                var oItemProject = new SuckerMenuItem("#", Resources.SharedResources.Project, this, "dropdown");

                Items.Insert(1, oItemProject);
                oItemProject.Items.Add(new SuckerMenuItem(string.Format("~/Projects/ProjectSummary/{0}", projectId), Resources.SharedResources.ProjectSummary, this));
                oItemProject.Items.Add(new SuckerMenuItem(string.Format("~/Projects/Roadmap/{0}", projectId), Resources.SharedResources.Roadmap, this));
                oItemProject.Items.Add(new SuckerMenuItem(string.Format("~/Projects/ChangeLog/{0}", projectId), Resources.SharedResources.ChangeLog, this));
                oItemProject.Items.Add(new SuckerMenuItem(string.Format("~/Projects/ProjectCalendar.aspx?pid={0}", projectId), Resources.SharedResources.Calendar, this));

                if (!string.IsNullOrEmpty(ProjectManager.GetById(projectId).SvnRepositoryUrl))
                {
                    oItemProject.Items.Add(new SuckerMenuItem(string.Format("~/SvnBrowse/SubversionBrowser.aspx?pid={0}", projectId), Resources.SharedResources.Repository, this));
                }

                var oItemIssues = new SuckerMenuItem("#", Resources.SharedResources.Issues, this, "dropdown");

                oItemIssues.Items.Add(new SuckerMenuItem(string.Format("~/Issues/IssueList.aspx?pid={0}", projectId), Resources.SharedResources.Issues, this));
                oItemIssues.Items.Add(new SuckerMenuItem(string.Format("~/Queries/QueryList.aspx?pid={0}", projectId), Resources.SharedResources.Queries, this));
                Items.Insert(2, oItemIssues);

                if (HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    //check add issue permission
                    if (UserManager.HasPermission(projectId, Common.Permission.AddIssue.ToString()))
                    {
                        Items.Add(new SuckerMenuItem(string.Format("~/Issues/CreateIssue/{0}", projectId), Resources.SharedResources.NewIssue, this));
                    }
                }
            }

            if (!HttpContext.Current.User.Identity.IsAuthenticated)
            {
                return;
            }

            var oItemAdmin = new SuckerMenuItem("#", Resources.SharedResources.Admin, this, "navbar-admin");

            if (projectId > Globals.NEW_ID && (UserManager.IsInRole(projectId, Globals.ProjectAdminRole) || UserManager.IsSuperUser()))
            {
                oItemAdmin.Items.Add(new SuckerMenuItem(string.Format("~/Administration/Projects/EditProject/{0}", projectId), Resources.SharedResources.EditProject, this, "admin"));
            }

            if (UserManager.IsSuperUser())
            {
                oItemAdmin.Items.Add(new SuckerMenuItem("~/Administration/Projects/ProjectList", Resources.SharedResources.Projects, this));
                oItemAdmin.Items.Add(new SuckerMenuItem("~/Administration/Users/UserList", Resources.SharedResources.UserAccounts, this));
                oItemAdmin.Items.Add(new SuckerMenuItem("~/Administration/Host/Settings", Resources.SharedResources.ApplicationConfiguration, this));
                oItemAdmin.Items.Add(new SuckerMenuItem("~/Administration/Host/LogViewer", Resources.SharedResources.LogViewer, this));
            }

            if (oItemAdmin.Items.Count > 0)
            {
                Items.Add(oItemAdmin);
            }
        }
Exemplo n.º 11
0
 public ListGroup()
 {
     Items.Add(new ListItem {
         IsDummy = true
     });
 }                                                                  // Dummy item is workaround for multiple Xamarin Forms bugs with empty groups / nested lists
Exemplo n.º 12
0
        public OpenDialogViewModel()
        {
            OpenDialogModel model = new OpenDialogModel();

            Items.Add(model.GetComputer());
        }
Exemplo n.º 13
0
 public void AddToCart(Food food, int amount)
 {
     Items.Add(food);
     Amounts.Add(amount);
 }
Exemplo n.º 14
0
 public CustomDropdown(ColorPickerUIAdv controls)
 {
     Items.Add(new ToolStripControlHost(controls));
 }
Exemplo n.º 15
0
        public SpacingViewModel(OptionStore optionStore, IServiceProvider serviceProvider) : base(optionStore, serviceProvider, LanguageNames.CSharp)
        {
            Items.Add(new HeaderItemViewModel()
            {
                Header = CSharpVSResources.Set_spacing_for_method_declarations
            });

            Items.Add(new CheckBoxOptionViewModel(CSharpFormattingOptions.SpacingAfterMethodDeclarationName, CSharpVSResources.Insert_space_between_method_name_and_its_opening_parenthesis2, s_methodPreview, this, optionStore));
            Items.Add(new CheckBoxOptionViewModel(CSharpFormattingOptions.SpaceWithinMethodDeclarationParenthesis, CSharpVSResources.Insert_space_within_parameter_list_parentheses, s_methodPreview, this, optionStore));
            Items.Add(new CheckBoxOptionViewModel(CSharpFormattingOptions.SpaceBetweenEmptyMethodDeclarationParentheses, CSharpVSResources.Insert_space_within_empty_parameter_list_parentheses, s_methodPreview, this, optionStore));

            Items.Add(new HeaderItemViewModel()
            {
                Header = CSharpVSResources.Set_spacing_for_method_calls
            });

            Items.Add(new CheckBoxOptionViewModel(CSharpFormattingOptions.SpaceAfterMethodCallName, CSharpVSResources.Insert_space_between_method_name_and_its_opening_parenthesis1, s_methodPreview, this, optionStore));
            Items.Add(new CheckBoxOptionViewModel(CSharpFormattingOptions.SpaceWithinMethodCallParentheses, CSharpVSResources.Insert_space_within_argument_list_parentheses, s_methodPreview, this, optionStore));
            Items.Add(new CheckBoxOptionViewModel(CSharpFormattingOptions.SpaceBetweenEmptyMethodCallParentheses, CSharpVSResources.Insert_space_within_empty_argument_list_parentheses, s_methodPreview, this, optionStore));

            Items.Add(new HeaderItemViewModel()
            {
                Header = CSharpVSResources.Set_other_spacing_options
            });

            Items.Add(new CheckBoxOptionViewModel(CSharpFormattingOptions.SpaceAfterControlFlowStatementKeyword, CSharpVSResources.Insert_space_after_keywords_in_control_flow_statements, s_forDelimiterPreview, this, optionStore));
            Items.Add(new CheckBoxOptionViewModel(CSharpFormattingOptions.SpaceWithinExpressionParentheses, CSharpVSResources.Insert_space_within_parentheses_of_expressions, s_expressionPreview, this, optionStore));
            Items.Add(new CheckBoxOptionViewModel(CSharpFormattingOptions.SpaceWithinCastParentheses, CSharpVSResources.Insert_space_within_parentheses_of_type_casts, s_castPreview, this, optionStore));
            Items.Add(new CheckBoxOptionViewModel(CSharpFormattingOptions.SpaceWithinOtherParentheses, CSharpVSResources.Insert_spaces_within_parentheses_of_control_flow_statements, s_forDelimiterPreview, this, optionStore));
            Items.Add(new CheckBoxOptionViewModel(CSharpFormattingOptions.SpaceAfterCast, CSharpVSResources.Insert_space_after_cast, s_castPreview, this, optionStore));
            Items.Add(new CheckBoxOptionViewModel(CSharpFormattingOptions.SpacesIgnoreAroundVariableDeclaration, CSharpVSResources.Ignore_spaces_in_declaration_statements, s_declarationSpacingPreview, this, optionStore));

            Items.Add(new HeaderItemViewModel()
            {
                Header = CSharpVSResources.Set_spacing_for_brackets
            });

            Items.Add(new CheckBoxOptionViewModel(CSharpFormattingOptions.SpaceBeforeOpenSquareBracket, CSharpVSResources.Insert_space_before_open_square_bracket, s_bracketPreview, this, optionStore));
            Items.Add(new CheckBoxOptionViewModel(CSharpFormattingOptions.SpaceBetweenEmptySquareBrackets, CSharpVSResources.Insert_space_within_empty_square_brackets, s_bracketPreview, this, optionStore));
            Items.Add(new CheckBoxOptionViewModel(CSharpFormattingOptions.SpaceWithinSquareBrackets, CSharpVSResources.Insert_spaces_within_square_brackets, s_bracketPreview, this, optionStore));

            Items.Add(new HeaderItemViewModel()
            {
                Header = CSharpVSResources.Set_spacing_for_delimiters
            });

            Items.Add(new CheckBoxOptionViewModel(CSharpFormattingOptions.SpaceAfterColonInBaseTypeDeclaration, CSharpVSResources.Insert_space_after_colon_for_base_or_interface_in_type_declaration, s_baseColonPreview, this, optionStore));
            Items.Add(new CheckBoxOptionViewModel(CSharpFormattingOptions.SpaceAfterComma, CSharpVSResources.Insert_space_after_comma, s_delimiterPreview, this, optionStore));
            Items.Add(new CheckBoxOptionViewModel(CSharpFormattingOptions.SpaceAfterDot, CSharpVSResources.Insert_space_after_dot, s_delimiterPreview, this, optionStore));
            Items.Add(new CheckBoxOptionViewModel(CSharpFormattingOptions.SpaceAfterSemicolonsInForStatement, CSharpVSResources.Insert_space_after_semicolon_in_for_statement, s_forDelimiterPreview, this, optionStore));
            Items.Add(new CheckBoxOptionViewModel(CSharpFormattingOptions.SpaceBeforeColonInBaseTypeDeclaration, CSharpVSResources.Insert_space_before_colon_for_base_or_interface_in_type_declaration, s_baseColonPreview, this, optionStore));
            Items.Add(new CheckBoxOptionViewModel(CSharpFormattingOptions.SpaceBeforeComma, CSharpVSResources.Insert_space_before_comma, s_delimiterPreview, this, optionStore));
            Items.Add(new CheckBoxOptionViewModel(CSharpFormattingOptions.SpaceBeforeDot, CSharpVSResources.Insert_space_before_dot, s_delimiterPreview, this, optionStore));
            Items.Add(new CheckBoxOptionViewModel(CSharpFormattingOptions.SpaceBeforeSemicolonsInForStatement, CSharpVSResources.Insert_space_before_semicolon_in_for_statement, s_forDelimiterPreview, this, optionStore));

            Items.Add(new HeaderItemViewModel()
            {
                Header = CSharpVSResources.Set_spacing_for_operators
            });

            Items.Add(new RadioButtonViewModel <BinaryOperatorSpacingOptions>(CSharpVSResources.Ignore_spaces_around_binary_operators, s_expressionSpacingPreview, "binary", BinaryOperatorSpacingOptions.Ignore, CSharpFormattingOptions.SpacingAroundBinaryOperator, this, OptionStore));
            Items.Add(new RadioButtonViewModel <BinaryOperatorSpacingOptions>(CSharpVSResources.Remove_spaces_before_and_after_binary_operators, s_expressionSpacingPreview, "binary", BinaryOperatorSpacingOptions.Remove, CSharpFormattingOptions.SpacingAroundBinaryOperator, this, OptionStore));
            Items.Add(new RadioButtonViewModel <BinaryOperatorSpacingOptions>(CSharpVSResources.Insert_space_before_and_after_binary_operators, s_expressionSpacingPreview, "binary", BinaryOperatorSpacingOptions.Single, CSharpFormattingOptions.SpacingAroundBinaryOperator, this, OptionStore));
        }
Exemplo n.º 16
0
        /// <summary>
        /// Called when [source collection changed].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.Collections.Specialized.NotifyCollectionChangedEventArgs"/> instance containing the event data.</param>
        private void OnSourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
            {
                var newItemList = new List <TTarget>();
                for (int ii = e.NewItems.Count - 1; ii >= 0; ii--)
                {
                    var newItem          = (TSource)e.NewItems[ii];
                    var newItemTransform = Transform(newItem);
                    InsertItem(e.NewStartingIndex + ii, newItemTransform);
                    newItemList.Add(newItemTransform);
                }

                newItemList.Reverse();
                OnPropertyChanged(new PropertyChangedEventArgs("Count"));
                OnPropertyChanged(new PropertyChangedEventArgs("Item[]"));
                OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, newItemList, e.NewStartingIndex));
                break;
            }

            case NotifyCollectionChangedAction.Remove:
            {
                var oldItemList = new List <TTarget>();
                for (int ii = e.OldItems.Count - 1; ii >= 0; ii--)
                {
                    oldItemList.Add(Items[ii]);
                    RemoveAt(e.OldStartingIndex + ii);
                }

                oldItemList.Reverse();
                OnPropertyChanged(new PropertyChangedEventArgs("Count"));
                OnPropertyChanged(new PropertyChangedEventArgs("Item[]"));
                OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, oldItemList, e.OldStartingIndex));
                break;
            }

            case NotifyCollectionChangedAction.Replace:
            {
                for (int ii = e.NewItems.Count - 1; ii >= 0; ii--)
                {
                    var newItem = Transform((TSource)e.NewItems[ii]);
                    var oldItem = Items[e.NewStartingIndex + ii];
                    Items[e.NewStartingIndex + ii] = newItem;
                    OnCollectionChanged(new NotifyCollectionChangedEventArgs(
                                            NotifyCollectionChangedAction.Replace,
                                            newItem,
                                            oldItem,
                                            e.NewStartingIndex + ii));
                }
                break;
            }

            case NotifyCollectionChangedAction.Move:
                throw new NotSupportedException();

            case NotifyCollectionChangedAction.Reset:
                Items.Clear();
                foreach (var item in SourceCollection)
                {
                    Items.Add(Transform(item));
                }

                OnPropertyChanged(new PropertyChangedEventArgs("Count"));
                OnPropertyChanged(new PropertyChangedEventArgs("Item[]"));
                OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
                break;
            }
        }
Exemplo n.º 17
0
        public RptViewWin(RptInfo p_info)
        {
            // 确保RptInfo已初始化,因含异步!

            IRptSearchForm searchForm = null;

            if (p_info.ScriptObj != null)
            {
                p_info.ScriptObj.View = _view;
                searchForm            = p_info.ScriptObj.GetSearchForm(p_info);
            }

            Main wc   = new Main();
            var  tabs = new Tabs();
            var  tab  = new Tab {
                Title = "内容"
            };

            tab.Content = _view;
            tabs.Items.Add(tab);
            wc.Items.Add(tabs);
            Items.Add(wc);

            var setting = p_info.Root.ViewSetting;

            if (setting.ShowMenu)
            {
                var menu = new Menu();
                if (!setting.ShowSearchForm &&
                    (searchForm != null || p_info.Root.Params.ExistXaml))
                {
                    menu.Items.Add(new Mi {
                        ID = "查询", Icon = Icons.搜索, Cmd = _view.CmdSearch
                    });
                }
                menu.Items.Add(new Mi {
                    ID = "导出", Icon = Icons.导出, Cmd = _view.CmdExport
                });
                menu.Items.Add(new Mi {
                    ID = "打印", Icon = Icons.打印, Cmd = _view.CmdPrint
                });
                p_info.ScriptObj?.InitMenu(menu);
                tab.Menu = menu;
            }

            if (setting.ShowSearchForm &&
                (searchForm != null || p_info.Root.Params.ExistXaml))
            {
                Pane wi = new Pane();
                tabs = new Tabs();
                tab  = new Tab {
                    Title = "查询"
                };

                // 加载查询面板内容
                if (searchForm == null)
                {
                    searchForm = new RptSearchForm(p_info);
                }
                tab.Menu          = searchForm.Menu;
                searchForm.Query += (s, e) => _view.LoadReport(e);
                tab.Content       = searchForm;

                tabs.Items.Add(tab);
                wi.Items.Add(tabs);
                Items.Add(wi);
            }

            // 初次加载自动执行查询
            if (setting.AutoQuery || p_info.Root.Params.Data.Count == 0)
            {
                _view.LoadReport(p_info);
            }
        }
Exemplo n.º 18
0
        private static void OnLoadingComplete(EventArgs args)
        {
            if (!_Player.ChampionName.Contains("Tristana"))
            {
                return;
            }
            Chat.Print("Bristana Loaded!", Color.GreenYellow);
            Chat.Print("Good Luck!", Color.GreenYellow);
            Bootstrap.Init(null);
            Q     = new Spell.Active(SpellSlot.Q);
            W     = new Spell.Skillshot(SpellSlot.W, 900, SkillShotType.Circular, 450, int.MaxValue, 180);
            E     = new Spell.Targeted(SpellSlot.E, 550);
            R     = new Spell.Targeted(SpellSlot.R, 550);
            Botrk = new Item(ItemId.Blade_of_the_Ruined_King);
            Bil   = new Item(3144, 475f);

            Menu = MainMenu.AddMenu("Bristana", "Bristana");
            Menu.AddGroupLabel("Bristana");
            Menu.AddLabel(" Please Select E Before Play ! ");

            SpellMenu = Menu.AddSubMenu("Combo Settings", "Combo");
            SpellMenu.AddGroupLabel("Combo Settings");
            SpellMenu.Add("ComboQ", new CheckBox("Spell [Q]"));
            SpellMenu.Add("ComboR", new CheckBox("Spell [R]"));
            SpellMenu.Add("ComboER", new CheckBox("Spell [ER]"));
            SpellMenu.AddGroupLabel("Combo [E] On");
            foreach (var target in EntityManager.Heroes.Enemies)
            {
                SpellMenu.Add("useECombo" + target.ChampionName, new CheckBox("" + target.ChampionName));
            }

            HarassMenu = Menu.AddSubMenu("Harass Settings", "Harass");
            HarassMenu.AddGroupLabel("Harass Settings");
            HarassMenu.Add("HarassQ", new CheckBox("Spell [Q]", false));
            HarassMenu.AddGroupLabel("Spell [E] on");
            foreach (var target in EntityManager.Heroes.Enemies)
            {
                HarassMenu.Add("HarassE" + target.ChampionName, new CheckBox("" + target.ChampionName));
            }
            HarassMenu.Add("manaHarass", new Slider("Min Mana For Harass", 50, 0, 100));

            LaneMenu = Menu.AddSubMenu("Laneclear Settings", "Clear");
            LaneMenu.AddGroupLabel("Laneclear Settings");
            LaneMenu.Add("ClearQ", new CheckBox("Spell [Q]", false));
            LaneMenu.Add("ClearE", new CheckBox("Spell [E]", false));
            LaneMenu.Add("ClearTower", new CheckBox("Spell [E] Turret", false));
            LaneMenu.Add("manaFarm", new Slider("Min Mana For LaneClear", 50, 0, 100));

            JungleMenu = Menu.AddSubMenu("JungleClear Settings", "JungleClear");
            JungleMenu.AddGroupLabel("JungleClear Settings");
            JungleMenu.Add("jungleQ", new CheckBox("Spell [Q]"));
            JungleMenu.Add("jungleE", new CheckBox("Spell [E]"));
            JungleMenu.Add("jungleW", new CheckBox("Spell [W]", false));
            JungleMenu.Add("manaJung", new Slider("Min Mana For JungleClear", 50, 0, 100));

            StealMenu = Menu.AddSubMenu("KillSteal Settings", "KS");
            StealMenu.AddGroupLabel("Killsteal Settings");
            StealMenu.Add("RKs", new CheckBox("Spell [R]"));

            Items = Menu.AddSubMenu("Items Settings", "Items");
            Items.AddGroupLabel("Items Settings");
            Items.Add("BOTRK", new CheckBox("Use [Botrk]"));
            Items.Add("ihp", new Slider("My HP Use BOTRK <=", 50));
            Items.Add("ihpp", new Slider("Enemy HP Use BOTRK <=", 50));

            Misc = Menu.AddSubMenu("Misc Settings", "Draw");
            Misc.AddGroupLabel("Anti Gapcloser");
            Misc.Add("antiGap", new CheckBox("Anti Gapcloser"));
            Misc.Add("antiRengar", new CheckBox("Anti Rengar"));
            Misc.Add("antiKZ", new CheckBox("Anti Kha'Zix"));
            Misc.AddGroupLabel("Drawings Settings");
            Misc.Add("drawAA", new CheckBox("Draw E"));
            Misc.Add("drawW", new CheckBox("Draw W", false));

            Skin = Menu.AddSubMenu("Skin Changer", "SkinChanger");
            Skin.Add("checkSkin", new CheckBox("Use Skin Changer"));
            Skin.Add("skin.Id", new ComboBox("Skin Mode", 0, "Classic", "Riot Tristana", "Earnest Elf Tristana", "Firefighter Tristana", "Guerilla Tristana", "Rocket Tristana", "Color Tristana", "Color Tristana", "Color Tristana", "Color Tristana", "Dragon Trainer Tristana"));


            Game.OnTick           += Game_OnTick;
            Drawing.OnDraw        += Drawing_OnDraw;
            Gapcloser.OnGapcloser += Gapcloser_OnGapCloser;
            GameObject.OnCreate   += GameObject_OnCreate;
        }
Exemplo n.º 19
0
 private void UpdateItems()
 {
     HatchStyle[] styles = new HatchStyle[] {
         HatchStyle.BackwardDiagonal,
         HatchStyle.Cross,
         HatchStyle.DarkDownwardDiagonal,
         HatchStyle.DarkHorizontal,
         HatchStyle.DarkUpwardDiagonal,
         HatchStyle.DarkVertical,
         HatchStyle.DashedDownwardDiagonal,
         HatchStyle.DashedHorizontal,
         HatchStyle.DashedUpwardDiagonal,
         HatchStyle.DashedVertical,
         HatchStyle.DiagonalBrick,
         HatchStyle.DiagonalCross,
         HatchStyle.Divot,
         HatchStyle.DottedDiamond,
         HatchStyle.DottedGrid,
         HatchStyle.ForwardDiagonal,
         HatchStyle.Horizontal,
         HatchStyle.HorizontalBrick,
         HatchStyle.LargeCheckerBoard,
         HatchStyle.LargeConfetti,
         HatchStyle.LightDownwardDiagonal,
         HatchStyle.LightHorizontal,
         HatchStyle.LightUpwardDiagonal,
         HatchStyle.LightVertical,
         HatchStyle.NarrowHorizontal,
         HatchStyle.NarrowVertical,
         HatchStyle.OutlinedDiamond,
         HatchStyle.Percent05,
         HatchStyle.Percent10,
         HatchStyle.Percent20,
         HatchStyle.Percent25,
         HatchStyle.Percent30,
         HatchStyle.Percent40,
         HatchStyle.Percent50,
         HatchStyle.Percent60,
         HatchStyle.Percent70,
         HatchStyle.Percent75,
         HatchStyle.Percent80,
         HatchStyle.Percent90,
         HatchStyle.Plaid,
         HatchStyle.Shingle,
         HatchStyle.SmallCheckerBoard,
         HatchStyle.SmallConfetti,
         HatchStyle.SmallGrid,
         HatchStyle.SolidDiamond,
         HatchStyle.Sphere,
         HatchStyle.Trellis,
         HatchStyle.Vertical,
         HatchStyle.Weave,
         HatchStyle.WideDownwardDiagonal,
         HatchStyle.WideUpwardDiagonal,
         HatchStyle.ZigZag
     };
     Items.Clear();
     foreach (HatchStyle style in styles)
     {
         Items.Add(style);
     }
 }
Exemplo n.º 20
0
 internal void BringWindowToFront(FloatWindow fw)
 {
     Items.Remove(fw);
     Items.Add(fw);
 }
Exemplo n.º 21
0
 public void AddMenuItem(IMenuItem item)
 {
     Items.Add(item);
     item.Click += ItemOnClick;
 }
Exemplo n.º 22
0
    // This subroutine is used to display a list of all files in the directory
    // currently selected by the user from the custom TreeView control.

    public void ShowFiles(string strDirectory)
    {
        // Save the directory name a field.

        this.strDirectory = strDirectory;
        Items.Clear();
        DirectoryInfo diDirectories = new DirectoryInfo(strDirectory);

        FileInfo[] afiFiles;
        try {
            // Call the convenient GetFiles method to get an array of all files
            // in the directory.
            afiFiles = diDirectories.GetFiles();
        } catch
        {
            return;
        }

        foreach (FileInfo fi in afiFiles)
        {
            // Create ListViewItem.
            ListViewItem lvi = new ListViewItem(fi.Name);
            // Assign ImageIndex based on filename extension.
            switch (Path.GetExtension(fi.Name).ToUpper())
            {
            case ".EXE":
            {
                lvi.ImageIndex = 1;
                break;
            }

            default:
            {
                lvi.ImageIndex = 0;
                break;
            }
            }

            // Add file length and last modified time sub-items.

            lvi.SubItems.Add(fi.Length.ToString("N0"));
            lvi.SubItems.Add(fi.LastWriteTime.ToString());

            // Add attribute subitem.

            string strAttr = string.Empty;

            if ((fi.Attributes & FileAttributes.Archive) != 0)
            {
                strAttr += "A";
            }

            if ((fi.Attributes & FileAttributes.Hidden) != 0)
            {
                strAttr += "H";
            }

            if ((fi.Attributes & FileAttributes.ReadOnly) != 0)
            {
                strAttr += "R";
            }

            if ((fi.Attributes & FileAttributes.System) != 0)
            {
                strAttr += "S";
            }

            lvi.SubItems.Add(strAttr);

            // Add completed ListViewItem to FileListView.

            Items.Add(lvi);
        }
    }
Exemplo n.º 23
0
 public BookFlyout3dVM()
 {
     OpenedBook = new OpenedBook3DViewModel();
     OpenedBook.CreatBookSides();
     Items.Add(OpenedBook);
 }
Exemplo n.º 24
0
 public virtual void AddItem(IAdventureItem item)
 {
     Items.Add(item);
 }
        public TitleMenuItem(MonoDevelop.Components.Commands.CommandManager manager, CommandEntry entry, CommandInfo commandArrayInfo = null, CommandSource commandSource = CommandSource.MainMenu, object initialCommandTarget = null)
        {
            this.manager = manager;
            this.initialCommandTarget = initialCommandTarget;
            this.commandSource        = commandSource;
            this.commandArrayInfo     = commandArrayInfo;

            menuEntry     = entry;
            menuEntrySet  = entry as CommandEntrySet;
            menuLinkEntry = entry as LinkCommandEntry;

            if (commandArrayInfo != null)
            {
                Header = commandArrayInfo.Text;

                var commandArrayInfoSet = commandArrayInfo as CommandInfoSet;
                if (commandArrayInfoSet != null)
                {
                    foreach (var item in commandArrayInfoSet.CommandInfos)
                    {
                        if (item.IsArraySeparator)
                        {
                            Items.Add(new Separator {
                                UseLayoutRounding = true,
                            });
                        }
                        else
                        {
                            Items.Add(new TitleMenuItem(manager, entry, item, commandSource, initialCommandTarget));
                        }
                    }
                }
            }

            if (menuEntrySet != null)
            {
                Header = menuEntrySet.Name;

                foreach (CommandEntry item in menuEntrySet)
                {
                    if (item.CommandId == MonoDevelop.Components.Commands.Command.Separator)
                    {
                        Items.Add(new Separator {
                            UseLayoutRounding = true,
                        });
                    }
                    else
                    {
                        Items.Add(new TitleMenuItem(manager, item));
                    }
                }
            }
            else if (menuLinkEntry != null)
            {
                Header = menuLinkEntry.Text;
                Click += OnMenuLinkClicked;
            }
            else if (entry != null)
            {
                actionCommand = manager.GetCommand(menuEntry.CommandId) as ActionCommand;
                if (actionCommand == null)
                {
                    return;
                }

                IsCheckable = actionCommand.ActionType == ActionType.Check;

                // FIXME: Use proper keybinding text.
                if (actionCommand.KeyBinding != null)
                {
                    InputGestureText = actionCommand.KeyBinding.ToString();
                }

                if (!actionCommand.Icon.IsNull)
                {
                    Icon = new Image {
                        Source = actionCommand.Icon.GetImageSource(Xwt.IconSize.Small)
                    }
                }
                ;
                Click += OnMenuClicked;
            }

            Height            = SystemParameters.CaptionHeight;
            UseLayoutRounding = true;
        }

        /// <summary>
        /// Updates a command entry. Should only be called from a toplevel node.
        /// This will update all the menu's children.
        /// </summary>
        void Update()
        {
            hasCommand = false;
            if (menuLinkEntry != null)
            {
                return;
            }

            if (menuEntrySet != null || commandArrayInfo is CommandInfoSet)
            {
                for (int i = 0; i < Items.Count; ++i)
                {
                    var titleMenuItem = Items[i] as TitleMenuItem;

                    if (titleMenuItem != null)
                    {
                        titleMenuItem.Update();
                        continue;
                    }

                    // If we have a separator, don't draw another one if the previous visible item is a separator.
                    var separatorMenuItem = Items [i] as Separator;
                    separatorMenuItem.Visibility = Visibility.Collapsed;
                    for (int j = i - 1; j >= 0; --j)
                    {
                        var iterMenuItem = Items [j] as Control;

                        if (iterMenuItem is Separator)
                        {
                            break;
                        }

                        if (iterMenuItem.Visibility != Visibility.Visible)
                        {
                            continue;
                        }

                        separatorMenuItem.Visibility = Visibility.Visible;
                        break;
                    }
                }
                if (menuEntrySet != null && menuEntrySet.AutoHide)
                {
                    Visibility = Items.Cast <Control> ().Any(item => item.Visibility == Visibility.Visible) ? Visibility.Visible : Visibility.Collapsed;
                }
                return;
            }

            var info = manager.GetCommandInfo(menuEntry.CommandId, new CommandTargetRoute(initialCommandTarget));

            if (actionCommand != null)
            {
                if (!string.IsNullOrEmpty(info.Description) && (string)ToolTip != info.Description)
                {
                    ToolTip = info.Description;
                }

                if (actionCommand.CommandArray && commandArrayInfo == null)
                {
                    Visibility = Visibility.Collapsed;

                    var parent = (TitleMenuItem)Parent;

                    int count       = 1;
                    int indexOfThis = parent.Items.IndexOf(this);
                    foreach (var child in info.ArrayInfo)
                    {
                        Control toAdd;
                        if (child.IsArraySeparator)
                        {
                            toAdd = new Separator();
                        }
                        else
                        {
                            toAdd = new TitleMenuItem(manager, menuEntry, child);
                        }

                        toRemoveFromParent.Add(toAdd);
                        parent.Items.Insert(indexOfThis + (count++), toAdd);
                    }
                    return;
                }
            }

            SetInfo(commandArrayInfo != null ? commandArrayInfo : info);
        }

        bool hasCommand = false;
        void SetInfo(CommandInfo info)
        {
            hasCommand = true;
            Header     = info.Text;
            Icon       = new Image {
                Source = info.Icon.GetImageSource(Xwt.IconSize.Small)
            };
            IsEnabled  = info.Enabled;
            Visibility = info.Visible && (menuEntry.DisabledVisible || IsEnabled) ?
                         Visibility.Visible : Visibility.Collapsed;
            IsChecked = info.Checked || info.CheckedInconsistent;
            ToolTip   = info.Description;
        }

        /// <summary>
        /// Clears a command entry's saved data. Should only be called from a toplevel node.
        /// This will update all the menu's children.
        /// </summary>
        IEnumerable <Control> Clear()
        {
            if (menuLinkEntry != null)
            {
                return(Enumerable.Empty <TitleMenuItem> ());
            }

            if (menuEntrySet != null)
            {
                var toRemove = Enumerable.Empty <Control> ();
                foreach (var item in Items)
                {
                    var titleMenuItem = item as TitleMenuItem;
                    if (titleMenuItem == null)
                    {
                        continue;
                    }

                    toRemove = toRemove.Concat(titleMenuItem.Clear());
                }

                foreach (var item in toRemove)
                {
                    Items.Remove(item);
                }

                return(Enumerable.Empty <TitleMenuItem> ());
            }

            var ret = toRemoveFromParent;

            toRemoveFromParent = new List <Control> ();
            return(ret);
        }
Exemplo n.º 26
0
        protected override void Init()
        {
            TabBar tabBar = new TabBar
            {
                Title = "Main",
                Route = "main",
                Items =
                {
                    new Tab
                    {
                        Route = "tab1",
                        Title = "Tab 1",
                        Items =
                        {
                            new ShellContent()
                            {
                                ContentTemplate = new DataTemplate(() => new ContentPage
                                {
                                    Content = new StackLayout
                                    {
                                        Children =
                                        {
                                            new Label  {
                                                Text = "Hej"
                                            },
                                            new Button {
                                                AutomationId = "goToShow",
                                                Text         = "Show",
                                                Command      = new Command(async() => await GoToAsync("//photos?id=1"))
                                            }
                                        }
                                    }
                                }),
                            }
                        }
                    }
                }
            };

            TabBar photosTab = new TabBar()
            {
                Title = "Photos",
                Route = "photos",
                Items =
                {
                    new ShellSection()
                    {
                        Items =
                        {
                            new ShellContent()
                            {
                                ContentTemplate = new DataTemplate(() => new PhotosPage()),
                            }
                        }
                    }
                }
            };

            Items.Add(tabBar);
            Items.Add(photosTab);
        }
Exemplo n.º 27
0
 /// <summary>
 /// Adds a <see cref="FlagCheckedListBoxItem"/> to the list.
 /// </summary>
 /// <param name="p_lbiEnumItem">The item to add to the list.</param>
 /// <returns>The added item.</returns>
 private FlagCheckedListBoxItem Add(FlagCheckedListBoxItem p_lbiEnumItem)
 {
     Items.Add(p_lbiEnumItem);
     return(p_lbiEnumItem);
 }
Exemplo n.º 28
0
        protected virtual void RefreshSRs()
        {
            Program.AssertOnEventThread();

            if (Empty)
            {
                Items.Add(new ToStringWrapper <VDI>(null, Messages.EMPTY)); //Create a special VDIWrapper for the empty dropdown item
            }
            if (connection == null)
            {
                return;
            }

            List <ToStringWrapper <SR> > items = new List <ToStringWrapper <SR> >();

            foreach (SR sr in connection.Cache.SRs)
            {
                if (sr.content_type != SR.Content_Type_ISO)
                {
                    continue;
                }

                if (DisplayPhysical && !sr.Physical())
                {
                    continue;
                }

                if (DisplayISO && (sr.Physical() || (noTools && sr.IsToolsSR())))
                {
                    continue;
                }

                if (vm == null && sr.IsBroken())
                {
                    continue;
                }

                if (vm != null)
                {
                    if (vm.power_state == vm_power_state.Halted)
                    {
                        Host storageHost = vm.GetStorageHost(true);
                        // The storage host is the host that the VM is bound to because the VM is using local storage on that host.
                        // It will be null if there is no such host (i.e. the VM is not restricted host-wise by storage).
                        if (storageHost != null && !sr.CanBeSeenFrom(storageHost))
                        {
                            // The storage host was not null, and this SR can't be seen from that host: don't show the SR.
                            continue;
                        }
                    }
                    else
                    {
                        // If VM is running, only show SRs on its current host
                        Host runningOn = vm.Connection.Resolve(vm.resident_on);
                        if (!sr.CanBeSeenFrom(runningOn))
                        {
                            continue;
                        }
                    }
                }

                items.Add(new ToStringWrapper <SR>(sr, sr.Name()));
            }

            if (items.Count > 0)
            {
                items.Sort();
                foreach (ToStringWrapper <SR> srWrapper in items)
                {
                    AddSR(srWrapper);
                }
            }
        }
Exemplo n.º 29
0
 private void AddItem(ItemViewModel itemViewModel)
 {
     Items.Add(itemViewModel);
 }
Exemplo n.º 30
0
        public void InitializeItems()
        {
            Items.Clear();

            if (Games?.Count == 0 && Game == null)
            {
                return;
            }

            if (Games != null)
            {
                // Set Favorites
                var favoriteItem = new MenuItem()
                {
                    Header           = resources.GetString("LOCFavoriteGame"),
                    Icon             = favoriteIcon,
                    Command          = model.SetAsFavoritesCommand,
                    CommandParameter = Games
                };

                Items.Add(favoriteItem);

                var unFavoriteItem = new MenuItem()
                {
                    Header           = resources.GetString("LOCRemoveFavoriteGame"),
                    Icon             = unFavoriteIcon,
                    Command          = model.RemoveAsFavoritesCommand,
                    CommandParameter = Games
                };

                Items.Add(unFavoriteItem);



                // Set Hide
                var hideItem = new MenuItem()
                {
                    Header           = resources.GetString("LOCHideGame"),
                    Icon             = hideIcon,
                    Command          = model.SetAsHiddensCommand,
                    CommandParameter = Games
                };

                Items.Add(hideItem);

                var unHideItem = new MenuItem()
                {
                    Header           = resources.GetString("LOCUnHideGame"),
                    Icon             = unHideIcon,
                    Command          = model.RemoveAsHiddensCommand,
                    CommandParameter = Games
                };

                Items.Add(unHideItem);

                // Edit
                var editItem = new MenuItem()
                {
                    Header           = resources.GetString("LOCEditGame"),
                    Icon             = editIcon,
                    Command          = model.EditGamesCommand,
                    CommandParameter = Games,
                    InputGestureText = model.EditSelectedGamesCommand.GestureText
                };

                Items.Add(editItem);

                // Set Category
                var categoryItem = new MenuItem()
                {
                    Header = resources.GetString("LOCSetGameCategory"),
                    //Icon = Images.GetEmptyImage(),
                    Command          = model.AssignGamesCategoryCommand,
                    CommandParameter = Games
                };

                Items.Add(categoryItem);
                Items.Add(new Separator());

                // Remove
                var removeItem = new MenuItem()
                {
                    Header           = resources.GetString("LOCRemoveGame"),
                    Icon             = removeIcon,
                    Command          = model.RemoveGamesCommand,
                    CommandParameter = Games,
                    InputGestureText = model.RemoveSelectedGamesCommand.GestureText
                };

                Items.Add(removeItem);
            }
            else if (Game != null)
            {
                // Play / Install / Buy
                if (ShowStartSection)
                {
                    bool added = false;
                    if (Game.IsInstalled)
                    {
                        var playItem = new MenuItem()
                        {
                            Header           = resources.GetString("LOCPlayGame"),
                            Icon             = startIcon,
                            FontWeight       = FontWeights.Bold,
                            Command          = model.StartGameCommand,
                            CommandParameter = Game,
                            InputGestureText = model.StartSelectedGameCommand.GestureText
                        };

                        Items.Add(playItem);
                        added = true;
                    }
                    else if (Game.IsStoreItem)
                    {
                        var installItem = new MenuItem()
                        {
                            Header           = $"{resources.GetString("LOCBuyGameLong")} {Game.PlayAction.Store} {resources.GetString("LOCBuyGamePrice")} {Game.PlayAction.Price}",
                            Icon             = buyIcon,
                            FontWeight       = FontWeights.Bold,
                            Command          = model.BuyGameCommand,
                            CommandParameter = Game
                        };

                        Items.Add(installItem);
                        added = true;
                    }
                    else if (!Game.IsCustomGame)
                    {
                        var installItem = new MenuItem()
                        {
                            Header           = resources.GetString("LOCInstallGame"),
                            Icon             = installIcon,
                            FontWeight       = FontWeights.Bold,
                            Command          = model.InstallGameCommand,
                            CommandParameter = Game
                        };

                        Items.Add(installItem);
                        added = true;
                    }
                    if (added)
                    {
                        Items.Add(new Separator());
                    }
                }

                // Custom Actions
                if (Game.OtherActions != null && Game.OtherActions.Count > 0)
                {
                    foreach (var task in Game.OtherActions)
                    {
                        var taskItem = new MenuItem()
                        {
                            Header = task.Name,
                            //Icon = Images.GetEmptyImage()
                        };

                        if (Game.IsStoreItem)
                        {
                            taskItem.Header = $"{resources.GetString("LOCBuyGameLong")} {task.Store} {resources.GetString("LOCBuyGamePrice")} {task.Price}";
                        }

                        taskItem.Click += (s, e) =>
                        {
                            model.GamesEditor.ActivateAction(Game, task);
                        };

                        Items.Add(taskItem);
                    }

                    Items.Add(new Separator());
                }

                // Links
                if (Game.Links?.Any() == true)
                {
                    var linksItem = new MenuItem()
                    {
                        Header = resources.GetString("LOCLinksLabel"),
                        Icon   = linksIcon
                    };

                    foreach (var link in Game.Links)
                    {
                        linksItem.Items.Add(new MenuItem()
                        {
                            Header           = link.Name,
                            Command          = Commands.GlobalCommands.NavigateUrlCommand,
                            CommandParameter = link.Url
                        });
                    }

                    Items.Add(linksItem);
                    Items.Add(new Separator());
                }

                // Open Game Location
                if (Game.IsInstalled)
                {
                    var locationItem = new MenuItem()
                    {
                        Header           = resources.GetString("LOCOpenGameLocation"),
                        Icon             = browseIcon,
                        Command          = model.OpenGameLocationCommand,
                        CommandParameter = Game
                    };

                    Items.Add(locationItem);
                }

                if (!Game.IsStoreItem)
                {
                    // Create Desktop Shortcut
                    var shortcutItem = new MenuItem()
                    {
                        Header           = resources.GetString("LOCCreateDesktopShortcut"),
                        Icon             = shortcutIcon,
                        Command          = model.CreateGameShortcutCommand,
                        CommandParameter = Game
                    };


                    Items.Add(shortcutItem);
                    Items.Add(new Separator());

                    // Toggle Favorites
                    var favoriteItem = new MenuItem()
                    {
                        Header           = Game.Favorite ? resources.GetString("LOCRemoveFavoriteGame") : resources.GetString("LOCFavoriteGame"),
                        Icon             = Game.Favorite ? unFavoriteIcon : favoriteIcon,
                        Command          = model.ToggleFavoritesCommand,
                        CommandParameter = Game
                    };

                    Items.Add(favoriteItem);

                    // Toggle Hide
                    var hideItem = new MenuItem()
                    {
                        Header           = Game.Hidden ? resources.GetString("LOCUnHideGame") : resources.GetString("LOCHideGame"),
                        Icon             = Game.Hidden ? unHideIcon : hideIcon,
                        Command          = model.ToggleVisibilityCommand,
                        CommandParameter = Game
                    };

                    Items.Add(hideItem);

                    // Edit
                    var editItem = new MenuItem()
                    {
                        Header           = resources.GetString("LOCEditGame"),
                        Icon             = editIcon,
                        Command          = model.EditGameCommand,
                        CommandParameter = Game,
                        InputGestureText = model.EditSelectedGamesCommand.GestureText
                    };

                    Items.Add(editItem);
                }

                // Set Category
                var categoryItem = new MenuItem()
                {
                    Header = resources.GetString("LOCSetGameCategory"),
                    //Icon = Images.GetEmptyImage(),
                    Command          = model.AssignGameCategoryCommand,
                    CommandParameter = Game
                };

                Items.Add(categoryItem);
                Items.Add(new Separator());

                // Remove
                var removeItem = new MenuItem()
                {
                    Header           = resources.GetString("LOCRemoveGame"),
                    Icon             = removeIcon,
                    Command          = model.RemoveGameCommand,
                    CommandParameter = Game,
                    InputGestureText = model.RemoveGameCommand.GestureText
                };

                Items.Add(removeItem);

                if (!Game.IsStoreItem)
                {
                    // Uninstall
                    if (!Game.IsCustomGame && Game.IsInstalled)
                    {
                        var uninstallItem = new MenuItem()
                        {
                            Header = resources.GetString("LOCUninstallGame"),
                            //Icon = Images.GetEmptyImage(),
                            Command          = model.UninstallGameCommand,
                            CommandParameter = Game
                        };

                        Items.Add(uninstallItem);
                    }
                }
            }
        }