コード例 #1
0
 protected new void Add()
 {
     if (!this.Disabled)
     {
         string     viewStateString = base.GetViewStateString("ID");
         TreeviewEx treeviewEx      = this.FindControl(viewStateString + "_all") as TreeviewEx;
         Assert.IsNotNull(treeviewEx, typeof(DataTreeview));
         Listbox listbox = this.FindControl(viewStateString + "_selected") as Listbox;
         Assert.IsNotNull(listbox, typeof(Listbox));
         Item selectionItem = treeviewEx.GetSelectionItem();
         if (selectionItem == null)
         {
             SheerResponse.Alert("Select an item in the Content Tree.", new string[0]);
         }
         else if (!this.HasExcludeTemplateForSelection(selectionItem))
         {
             if (this.IsDeniedMultipleSelection(selectionItem, listbox))
             {
                 SheerResponse.Alert("You cannot select the same item twice.", new string[0]);
             }
             else if (this.HasIncludeTemplateForSelection(selectionItem))
             {
                 SheerResponse.Eval("scForm.browser.getControl('" + viewStateString + "_selected').selectedIndex=-1");
                 ListItem control = new ListItem();
                 control.ID = GetUniqueID("L");
                 Sitecore.Context.ClientPage.AddControl(listbox, control);
                 control.Header = selectionItem.DisplayName;
                 control.Value  = control.ID + "|" + selectionItem.ID;
                 SheerResponse.Refresh(listbox);
                 SetModified();
             }
         }
     }
 }
コード例 #2
0
 private void Listbox_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button != MouseButtons.Left)
     {
         return;
     }
     Listbox.SelectedIndexChanged -= Listbox_SelectedIndexChanged;
     if (Listbox.Items.Count <= 0)
     {
         return;
     }
     OnSelectionNotReady?.Invoke(this, EventArgs.Empty);
     if (CheckIfThumbMouseButtonsHaveBeenPressed(e))
     {
         return;
     }
     _mouseDownIndex = Listbox.IndexFromPoint(e.Location);
     //if selection starts beneath the listbox, we don't want anything selected,
     //since the selection is "buggy" and doesn't select as one would assume.
     if (_mouseDownIndex != -1)
     {
         return;
     }
     if (Listbox.SelectedIndex != -1)
     {
         Listbox.SetSelected(Listbox.SelectedIndex, false);
     }
     Listbox.Enabled = false;
     Listbox.Enabled = true;
 }
コード例 #3
0
ファイル: ButtonsForm.cs プロジェクト: piwi1263/Tinkr
        private void TestEvents(object sender, point point)
        {
            _panel           = GetNewRootPanel();
            _panel.Suspended = true;
            _panel.BackColor = 0;

            var lst = new Listbox("lst", Fonts.Droid9, 5, 35, _panel.Width - 10, _panel.Height - 40);

            var btn = new Button("btn", "Tab me ... tap me hard", Fonts.Droid11, 5, 5);

            btn.Tap            += (o, point1) => lst.AddItem(new ListboxItem("Tap"));
            btn.TapHold        += (o, point1) => lst.AddItem(new ListboxItem("TapHold"));
            btn.DoubleTap      += (o, point1) => lst.AddItem(new ListboxItem("DoubleTap"));
            btn.TouchDown      += (o, point1) => lst.AddItem(new ListboxItem("TouchDown"));
            btn.TouchMove      += (o, point1) => lst.AddItem(new ListboxItem("TouchMove"));
            btn.TouchUp        += (o, point1) => lst.AddItem(new ListboxItem("TouchUp"));
            btn.TouchGesture   += (o, type, force) => lst.AddItem(new ListboxItem("TouchGesture"));
            btn.GotFocus       += (o) => lst.AddItem(new ListboxItem("GotFocus"));
            btn.LostFocus      += (o) => lst.AddItem(new ListboxItem("LostFocus"));
            btn.ButtonPressed  += (o, id) => lst.AddItem(new ListboxItem("ButtonPressed"));
            btn.ButtonReleased += (o, id) => lst.AddItem(new ListboxItem("ButtonReleased"));
            btn.KeyboardAltKey += (o, key, pressed) => lst.AddItem(new ListboxItem("KeyboardAltKey"));
            btn.KeyboardKey    += (o, key, pressed) => lst.AddItem(new ListboxItem("KeyboardKey"));

            _panel.AddChild(btn);

            btn = new Button("btn2", "Other button", Fonts.Droid11, 200, 5);
            _panel.AddChild(btn);

            _panel.AddChild(lst);

            _panel.Suspended = false;
        }
コード例 #4
0
        public override void InstantiateComponents()
        {
            itemsBox             = new Listbox <Item>(5, 4);
            itemsBox.Autoselect  = false;
            itemsBox.Multiselect = true;
            itemsBox.Width       = 30;
            itemsBox.Height      = 20;
            RegisterControl(itemsBox);

            itemInfo             = new Label(40, 15);
            itemInfo.Width       = 50;
            itemInfo.IsMultiline = true;
            RegisterControl(itemInfo);

            RegisterControl(new Label(5, 2)
            {
                Text = "Inventory - Press <ESC> to go back", Foreground = ConsoleColor.Gray
            });

            itemImage             = new Image(40, 4);
            itemImage.Border      = Cuit.Helpers.RectangleDrawStyle.Single;
            itemImage.BorderColor = ConsoleColor.White;
            itemImage.IsVisible   = false;

            RegisterControl(itemImage);

            itemsBox.SelectionChanged += ItemsBox_SelectionChanged;
            itemsBox.PreviewChanged   += ItemsBox_PreviewChanged;
        }
コード例 #5
0
        public override void Execute(CommandContext context)
        {
            Assert.ArgumentNotNull(context, nameof(context));

            string fieldId = context.Parameters["id"] ?? "";
            string id      = "";

            //this is specific to Treelist. The selected item will have the _Selected suffix after its ID
            var control = Sitecore.Context.ClientPage.FindControl(fieldId + "_Selected");

            if (control != null && control is Listbox)
            {
                Listbox listBox = (Listbox)control;

                if (listBox?.Selected != null && listBox.Selected.Length > 0)
                {
                    //the listbox stores pipe delimited values, the value to the right of the pipe is the ID of the target item
                    var ids = listBox.Selected[0].Value.Split('|');

                    if (ids != null && ids.Length > 0)
                    {
                        //id[0] stores the <option> id which we don't need
                        id = ids[1];
                    }
                }
            }

            ClientPipelineArgs args = new ClientPipelineArgs();

            args.Parameters["id"] = id;

            Context.ClientPage.Start(this, "Run", args);
        }
コード例 #6
0
        private void Listbox_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            ThisIndexHasBeenChangedProgrammatically = -1;
            if (Listbox.SelectedIndex == -1) //true when nothing is selected
            {
            }
            else if (!CheckIfThumbMouseButtonsHaveBeenPressed(e))
            {
                if (Listbox.Items.Count > 0)
                {
                    Listbox.MouseDown -= Listbox_MouseDown;
                    _mouseUpIndex      = Listbox.IndexFromPoint(Listbox.PointToClient(Cursor.Position));
                    HandleSelectionChange();
                    if (Listbox.SelectedIndex != -1)
                    {
                        OnSelectionReady?.Invoke(this, EventArgs.Empty);
                    }
                }
            }

            Listbox.SelectedIndexChanged += Listbox_SelectedIndexChanged;
        }
コード例 #7
0
    void RefreshEditor()
    {
        if (chunk.objects == null)
        {
            return;
        }
        string[] chunkItems = new string[chunk.objects.Count];
        for (int i = 0; i < chunkItems.Length; i++)
        {
            chunkItems[i] = chunk.objects[i].texture + "." + chunk.objects[i].id.ToString();
        }
        ChunkItemList = new Listbox(chunkItems, "Items", new Rect(10, 480, 200, 140), 20);

        string[] savedChunks = CubeFile.CheckDirectory("SavedFiles/Chunks");
        SavedChunksList = new Listbox(savedChunks, "SavedChunks", new Rect(10, 295, 200, 140), 20);
        foreach (var item in SavedChunksList.items)
        {
            item.action = window.LoadChunk;
            Debug.Log(item.content[0].text + " " + chunk.Name);
            if (item.content[0].text.Contains(chunk.Name))
            {
                SavedChunksList.SelectItem(item.id);
            }
        }
        //chunk = new Chunk("NewChunk", new Rect(0, 0, 1, 1), 0, 0, new List<LevelObj>(), 0);
    }
コード例 #8
0
        private void InitializeComponent()
        {
            this.Size     = new Vector2(280, 200);
            this.Position = new Vector2(SharedInformation.Config.ScreenWidth / 2 - 140, SharedInformation.Config.ScreenHeight - 140 - 200);
            this.Text     = "Service Select";

            lstServices             = new Listbox();
            lstServices.Size        = new Vector2(256, 143);
            lstServices.Position    = new Vector2(12, 21);
            lstServices.OnActivate += new Action(lstServices_OnActivate);

            btnOK          = new Button();
            btnOK.Text     = "OK";
            btnOK.Position = new Vector2(189, 176);
            btnOK.Size     = new Vector2(42, 20);
            btnOK.Clicked += new Action <MouseButtons, float, float>(btnOK_Clicked);

            btnCancel          = new Button();
            btnCancel.Clicked += new Action <Nuclex.Input.MouseButtons, float, float>(btnCancel_Clicked);
            btnCancel.Text     = "Exit";
            btnCancel.Position = new Vector2(234, 176);
            btnCancel.Size     = new Vector2(42, 20);

            this.Controls.Add(lstServices);
            this.Controls.Add(btnOK);
            this.Controls.Add(btnCancel);
        }
コード例 #9
0
        static Listbox LoadListbox(Stream fs)
        {
            var obj = new Listbox(ReadString(fs), ReadFont(fs), ReadInt(fs), ReadInt(fs), ReadInt(fs), ReadInt(fs), ReadBool(fs), ReadBool(fs), ReadSize(fs))
            {
                Enabled           = ReadBool(fs),
                Visible           = ReadBool(fs),
                BackColor         = ReadColor(fs),
                MinimumLineHeight = ReadInt(fs),
                SelectedBackColor = ReadColor(fs),
                SelectedTextColor = ReadColor(fs),
                ZebraStripe       = ReadBool(fs),
                ZebraStripeColor  = ReadColor(fs)
            };

            var len = ReadInt(fs);

            for (var i = 0; i < len; i++)
            {
                if (fs.ReadByte() != 7)
                {
                    throw new Exception("Invalid item type; expected 7");
                }
                obj.AddItem(new ListboxItem(ReadString(fs), ReadFont(fs), ReadColor(fs), ReadImage(fs), ReadBool(fs), ReadBool(fs)));
            }

            return(obj);
        }
コード例 #10
0
 public void ListDirectory(FtpClient client, string path, Listbox listbox) 
 { 
       // stuff
       listbox.Items.Add(item.FullName))       
       // stuff
       ListDirectory(client, item.FullName, listbox); 
 }
コード例 #11
0
            public void Main()
            {
                Button b1 = new Button(DarkTheme.ControlDefaultBackground, 10, 10, 100, 75, "hell0");
                Button b2 = new Button(DarkTheme.ControlDefaultBackground, 120, 10, 250, 75, "a btn");
                Button b3 = new Button(DarkTheme.ControlDefaultBackground, 10, 95, 360, 100, "another btn xddd");

                b1.Clicked += B1_Clicked;
                b2.Clicked += B1_Clicked;
                b3.Clicked += B1_Clicked;

                Listbox lb = new Listbox(DarkTheme.ContainerBackgroundColour, 10, 215, 400, 500);

                lb.AddItem(new ListboxItem(DarkTheme.ControlDefaultBackground, "listbox1"));
                lb.AddItem(new ListboxItem(DarkTheme.ControlDefaultBackground, "listbox2"));
                lb.AddItem(new ListboxItem(DarkTheme.ControlDefaultBackground, "listbox3"));
                lb.AddItem(new ListboxItem(DarkTheme.ControlDefaultBackground, "listbox4"));
                listboxes.Add(lb);

                buttons.Add(b1);
                buttons.Add(b2);
                buttons.Add(b3);

                GameEngine ge = new GameEngine(this);

                ge.Construct(1280, 720, 1, 1, 60);
                ge.Start();
            }
コード例 #12
0
        public override void InstantiateComponents()
        {
            base.InstantiateComponents();

            _battleActionListBox        = new Listbox <BattleActions>(5, 1);
            _battleActionListBox.Width  = 15;
            _battleActionListBox.Height = 6;
            RegisterControl(_battleActionListBox);

            _outputBox         = new OutputBox(24, 2);
            _outputBox.Width   = Application.Width - 25;
            _outputBox.MaxRows = 6;
            RegisterControl(_outputBox);

            _playerHealth       = new Progressbar(6, 9);
            _playerHealth.Width = 40;
            RegisterControl(_playerHealth);

            _playerImage = new Image(6, 12);
            RegisterControl(_playerImage);

            _enemyHealth       = new Progressbar(55, 9);
            _enemyHealth.Width = 40;
            RegisterControl(_enemyHealth);

            _enemyImage = new Image(55, 12);
            RegisterControl(_enemyImage);

            _battleActionListBox.SelectionChanged += _battleActionListBox_SelectionChanged;

            _playerImage.SetImageFromFile("Resources/Encounters/Images/player.asc");

            _playerHealth.Maximum = GameManager.Instance.State.MaxHealth;
            _playerHealth.Value   = GameManager.Instance.State.Health;
        }
コード例 #13
0
 private void _reslistbox_ItemSelected(Label item, Listbox sender)
 {
     if (vmList.ContainsKey(item.Text.Text))
     {
         VideoMode sel = vmList[item.Text.Text];
         ConfigurationManager.SetResolution((uint)sel.Width, (uint)sel.Height);
     }
 }
コード例 #14
0
 private void _reslistbox_ItemSelected(Label item, Listbox sender)
 {
     if (vmList.ContainsKey(item.Text.Text))
     {
         VideoMode sel = vmList[item.Text.Text];
         ConfigurationManager.SetCVar("display.width", (int)sel.Width);
         ConfigurationManager.SetCVar("display.height", (int)sel.Height);
     }
 }
コード例 #15
0
        private void HandleFocus(EventArgs e)
        {
            if (IsEnabled)
            {
                Listbox.GoToOption(this);
                return;
            }

            Listbox.GoToOption(ListboxFocus.Nothing);
        }
コード例 #16
0
        public void createList()
        {
            Listbox.ItemsSource = factormap;
            Listbox.Width       = 500;
            KeyboardNavigation.SetTabNavigation(Listbox, KeyboardNavigationMode.Cycle);

            //Scroll to the bottom
            Listbox.SelectedIndex = Listbox.Items.Count - 1;
            Listbox.ScrollIntoView(Listbox.SelectedItem);
        }
コード例 #17
0
        private async Task HandleClick()
        {
            if (!IsEnabled)
            {
                return;
            }

            Listbox.CurrentValue = Value;

            await Listbox.Close();
        }
コード例 #18
0
        private void editEnum_ItemSelected(Label item, Listbox sender)
        {
            var field = (FieldInfo)sender.UserData;
            var state = Enum.Parse(field.FieldType, item.Text, true);

            if (field.IsInitOnly || field.IsLiteral)
            {
                return;
            }
            field.SetValue(_entity, state);
        }
コード例 #19
0
        static void Test_lists()
        {
            var frm = new Form(0, 0, Console.WindowWidth, Console.WindowHeight)
            {
                Title = "Options"
            };

            frm.AddChild(new Label(2, 2, "Listbox"));
            var lb = new Listbox(2, 3, 10, 5, new[] { "Balin", "Dwalin",
                                                      "Kili", "Fili",
                                                      "Oin", "Gloin",
                                                      "Ori", "Nori", "Dori",
                                                      "Bifur", "Bofur", "Bombur",
                                                      "Thorin" });

            lb.Items[0].BackgroundColor = ConsoleColor.DarkYellow;
            lb.Items[1].ForegroundColor = ConsoleColor.Red;

            lb.OnPressed += (s, e) => MessageBox.ShowInfo("Dwarf selected: " + lb.Items[lb.CurrentItemIndex].Text);
            frm.AddChild(lb);

            frm.AddChild(new Label(2, 9, "Combobox"));
            var cb = new Combobox(2, 10, 21, 5, new[] { "Paris", "London", "Oslo", "Berlin", "New York", "Tokyo", "Rio", "Prague" })
            {
                Label = "Your favorite city"
            };

            frm.AddChild(cb);

            frm.AddChild(new Label(24, 10, 20)
            {
                Text            = "Press down-arrow to open list of choices.\nPress ESC to close list of choices.",
                CanBeMultiline  = true,
                ForegroundColor = ConsoleColor.DarkGray
            });

            frm.AddChild(new Label(2, 9, "Combobox with text limited to list items"));
            var cb2 = new Combobox(2, 12, 21, 4, new[] { "XS", "S", "M", "L", "XL", "XXL" })
            {
                Label            = "Select your t-shirt size",
                LimitTextToItems = true
            };

            frm.AddChild(cb2);

            frm.AddChild(new Button(2, 14, 10, "Close")
            {
                OnPressed = (s, e) => {
                    BashForms.Close();
                }
            });

            BashForms.Open(frm);
        }
コード例 #20
0
 protected void HandleMouseLeave(MouseEventArgs e)
 {
     if (!IsEnabled)
     {
         return;
     }
     if (!IsActive)
     {
         return;
     }
     Listbox.GoToOption(ListboxFocus.Nothing);
 }
コード例 #21
0
        private void _lstResolution_ItemSelected(Label item, Listbox sender)
        {
            if (_videoModeList.ContainsKey(item.Text))
            {
                var sel = _videoModeList[item.Text];
                ConfigurationManager.SetCVar("display.width", (int)sel.Width);
                ConfigurationManager.SetCVar("display.height", (int)sel.Height);

                CluwneLib.UpdateVideoSettings();
                FormResize();
            }
        }
コード例 #22
0
    static void Init()
    {
        objSelectorGrid = new LevelObj(new Rect(0, 0, 0, 0), Resources.Load <Texture>("HexaGridRed"), 0, 0);

        grid          = new Grid(800, 400, new Rect(215, 90, 500, 400), 40, 40);
        ChunkItemList = new Listbox(new string[] { "None" }, "LevelChunksHirarchy", new Rect(10, 480, 200, 140), 20);

        window         = (ChuckEditor)EditorWindow.GetWindow(typeof(ChuckEditor));
        window.minSize = new Vector2(735, 650);
        chunk          = new Chunk("NewChunk", new Rect(0, 0, 1, 1), 0, 0, new List <LevelObj>());
        string[] savedChunks = CubeFile.CheckDirectory("SavedFiles/Chunks");
        window.Canvas = new ObjRect(180, 90, 800, 400);
        window.movingCenterOfChunk = false;
        SavedChunksList            = new Listbox(savedChunks, "SavedLevels", new Rect(10, 295, 200, 140), 20);
        window.autoAdjustCOC       = true;
        foreach (var item in SavedChunksList.items)
        {
            item.action = window.LoadChunk;
        }
        window.gridScalerRect = new Rect(715, 490, 20, 150);
        //foreach (var item in ChunkItemList.items)
        //{
        //    item.action = window.SelectItemOnScene;
        //}
        window.lastGrabbedObjScale = new Vector2(40, 40);
        window.deletedItems        = new List <string>(0);
        window.grabbedObj          = new Rect(0, 0, window.lastGrabbedObjScale.x, window.lastGrabbedObjScale.y);
        string[] availObjs = window.LoadAvailableObjects();

        TextureList = new Listbox(availObjs, "AvailableObjects", new Rect(10, 110, 200, 140), 20);

        foreach (var item in TextureList.items)
        {
            item.action = window.changeSelectedBlockTexture;
        }

        window.layers     = new bool[10];
        window.layers[0]  = true;
        window.layersName = new string[] { "L1",
                                           "L2",
                                           "L3",
                                           "L4",
                                           "L5",
                                           "L6",
                                           "L7",
                                           "L8",
                                           "L9",
                                           "L10" };

        window.wantsMouseMove = true;
        window.changeSelectedBlockTexture("");
    }
コード例 #23
0
        private void AddBtn_Click(object sender, RoutedEventArgs e)
        {
            string tmp = txtBox.Text.ToLower().Title();

            PassableList.Add(tmp);
            txtBox.Text = String.Empty;
            Listbox.ScrollIntoView(PassableList[PassableList.Count() - 1]);

            using (StreamWriter write = new StreamWriter(@"..\..\Resources\wordPoolData.txt", true))
            {
                write.WriteLine(tmp);
            }
        }
コード例 #24
0
    private Listbox CreateMainCategorySelectorControl()
    {
        var mainCategorySelectorControl = new Listbox
        {
            ID            = GetID(ControlNames.MainCategoryDropList),
            Disabled      = Disabled,
            TrackModified = false
        };

        InitialiseMainCategorySelectorControl(mainCategorySelectorControl);

        return(mainCategorySelectorControl);
    }
コード例 #25
0
 public ListItem(GUIContent GuiContent,
                 Rect BoundryBox,
                 int id,
                 Listbox parent)
 {
     this.boundryBox = BoundryBox;
     this.content    = new List <GUIContent>();
     this.content.Add(GuiContent);
     this.id     = id;
     this.parent = parent;
     isSelected  = true;
     ToggleSelection();
 }
コード例 #26
0
 private void CreateDebugPanel()
 {
     this.debugListbox = new Listbox(GameConfig.Fonts.Medium);
     this.debugListbox.PreferredSize = new Point(500, 20);
     this.debugListbox.IsDraggable   = true;
     this.debugListbox.AddElement("F1 for this list (global)");
     this.debugListbox.AddElement("F2 collision bounds (singleplayergame)");
     this.debugListbox.AddElement("F3 show performance stats (global)");
     this.debugListbox.AddElement("L toggle debug latency (global)");
     this.debugListbox.AddElement("F5 for mouse position (global)");
     this.debugListbox.AddElement("F8 GUI debug mode (global)");
     this.debugListbox.AddElement("F12 for borderless fullscreen (global)");
     this.debugListbox.Hide();
 }
コード例 #27
0
ファイル: MainDlg.cs プロジェクト: ralfw/ShellForms
        public MainDlg()
        {
            this.Title = "CSV Viewer";

            this.lstTable         = new Listbox(2, 2, Console.WindowWidth - 5, Console.WindowHeight - 5);
            lstTable.CanHaveFocus = false;
            base.Add(lstTable);

            var mb = new Menubar(2, Console.WindowHeight - 2);

            mb.Menuitems   = new[] { "First", "Last", "Exit" };
            mb.OnSelected += Menuitem_selected;
            base.Add(mb);
        }
コード例 #28
0
 public RuleSelectScreen()
 {
     BaseGame.ShowMouse = true;
     RuleLoader.Initial();
     string[] ruleLists = RuleLoader.GetRulesList();
     rulesList = new Listbox("rulelist", new Vector2(200, 150), new Point(400, 300), Color.WhiteSmoke, Color.Green);
     foreach (string rulename in ruleLists)
     {
         rulesList.AddItem(rulename);
     }
     rulesList.OnChangeSelection += new EventHandler(rulesList_OnChangeSelection);
     btn          = new TextButton("OkBtn", new Vector2(700, 500), "Begin", 0, Color.Blue);
     btn.OnClick += new EventHandler(btn_OnPress);
 }
コード例 #29
0
    public Listbox CreateSubCategorySelectorControl()
    {
        var subCategorySelectorControl = new Listbox
        {
            ID            = GetID(ControlNames.SubCategoryDropList),
            Disabled      = Disabled,
            TrackModified = false
        };

        InitialiseSubCategorySelectorControl(subCategorySelectorControl);
        subCategorySelectorControl.Value = CategoryIdPair.SubCategoryId.ToString();
        Sitecore.Context.ClientPage.ClientResponse.Refresh(subCategorySelectorControl);
        return(subCategorySelectorControl);
    }
コード例 #30
0
        public override void InstantiateComponents()
        {
            _menuList       = new Listbox <MenuAction>((Application.Width / 2) - 15, 11);
            _menuList.Width = 30;
            //_menuList.Height = 8;
            _menuList.SelectionChanged += _menuList_SelectionChanged;
            RegisterControl(_menuList);

            var title      = "Welcome to YetAnotherTextRPG";
            var titleLabel = new Label((Application.Width / 2) - (title.Length / 2), 8);

            titleLabel.Text       = title;
            titleLabel.Foreground = ConsoleColor.Green;
            RegisterControl(titleLabel);
        }
コード例 #31
0
        public ResourcePacksOptionControl(ScreenComponent manager)
            : base(manager)
        {
            Grid grid = new Grid(manager)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Stretch,
                Margin = Border.All(15),
            };
            Controls.Add(grid);

            grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 });
            grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Fixed, Width = 100 });
            grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 });
            grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Parts, Height = 1 });
            grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Auto, Height = 1 });
            grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Auto, Height = 1 });

            StackPanel buttons = new StackPanel(manager)
            {
                VerticalAlignment = VerticalAlignment.Stretch,
            };
            grid.AddControl(buttons, 1, 0);

            #region Manipulationsbuttons

            addButton = Button.TextButton(manager, "Add");
            addButton.HorizontalAlignment = HorizontalAlignment.Stretch;
            addButton.Visible = false;
            buttons.Controls.Add(addButton);

            removeButton = Button.TextButton(manager, "Remove");
            removeButton.HorizontalAlignment = HorizontalAlignment.Stretch;
            removeButton.Visible = false;
            buttons.Controls.Add(removeButton);

            moveUpButton = Button.TextButton(manager, "Up");
            moveUpButton.HorizontalAlignment = HorizontalAlignment.Stretch;
            moveUpButton.Visible = false;
            buttons.Controls.Add(moveUpButton);

            moveDownButton = Button.TextButton(manager, "Down");
            moveDownButton.HorizontalAlignment = HorizontalAlignment.Stretch;
            moveDownButton.Visible = false;
            buttons.Controls.Add(moveDownButton);

            #endregion

            applyButton = Button.TextButton(manager, "Apply");
            applyButton.HorizontalAlignment = HorizontalAlignment.Right;
            applyButton.VerticalAlignment = VerticalAlignment.Bottom;
            grid.AddControl(applyButton, 0, 2, 3);

            infoLabel = new Label(ScreenManager)
            {
                HorizontalTextAlignment = HorizontalAlignment.Left,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Top,
                WordWrap = true,
            };
            grid.AddControl(infoLabel, 0, 1, 3);

            #region Listen

            loadedPacksList = new Listbox<ResourcePack>(manager)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Stretch,
                SelectedItemBrush = new BorderBrush(Color.SaddleBrown * 0.7f),
                TemplateGenerator = ListTemplateGenerator,
            };

            grid.AddControl(loadedPacksList, 0, 0);

            activePacksList = new Listbox<ResourcePack>(manager)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Stretch,
                SelectedItemBrush = new BorderBrush(Color.SaddleBrown * 0.7f),
                TemplateGenerator = ListTemplateGenerator,
            };

            grid.AddControl(activePacksList, 2, 0);

            #endregion

            #region Info Grid

            //Grid infoGrid = new Grid(ScreenManager)
            //{
            //    HorizontalAlignment = HorizontalAlignment.Stretch,
            //};

            //infoGrid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Auto, Width = 1 });
            //infoGrid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 });
            //infoGrid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Auto, Height = 1 });
            //infoGrid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Auto, Height = 1 });
            //infoGrid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Auto, Height = 1 });

            //Label nameLabel = new Label(ScreenManager)
            //{
            //    Text = "Name:",
            //};
            //infoGrid.AddControl(nameLabel, 0, 0);

            //Label authorLabel = new Label(ScreenManager)
            //{
            //    Text = "Author:",
            //};
            //infoGrid.AddControl(authorLabel, 0, 1);

            //Label descriptionLabel = new Label(ScreenManager)
            //{
            //    Text = "Description:",
            //};
            //infoGrid.AddControl(descriptionLabel, 0, 2);

            //grid.AddControl(infoGrid, 0, 1, 3);

            #endregion

            loadedPacksList.SelectedItemChanged += loadedList_SelectedItemChanged;
            activePacksList.SelectedItemChanged += activeList_SelectedItemChanged;

            addButton.LeftMouseClick += (s, e) =>
            {
                ResourcePack pack = loadedPacksList.SelectedItem;
                loadedPacksList.Items.Remove(pack);
                activePacksList.Items.Add(pack);
                activePacksList.SelectedItem = pack;
            };

            removeButton.LeftMouseClick += (s, e) =>
            {
                ResourcePack pack = activePacksList.SelectedItem;
                activePacksList.Items.Remove(pack);
                loadedPacksList.Items.Add(pack);
                loadedPacksList.SelectedItem = pack;
            };

            moveUpButton.LeftMouseClick += (s, e) =>
            {
                ResourcePack pack = activePacksList.SelectedItem;
                if (pack == null)
                    return;

                int index = activePacksList.Items.IndexOf(pack);
                if (index > 0)
                {
                    activePacksList.Items.Remove(pack);
                    activePacksList.Items.Insert(index - 1, pack);
                    activePacksList.SelectedItem = pack;
                }
            };

            moveDownButton.LeftMouseClick += (s, e) =>
            {
                ResourcePack pack = activePacksList.SelectedItem;
                if (pack == null) return;

                int index = activePacksList.Items.IndexOf(pack);
                if (index < activePacksList.Items.Count - 1)
                {
                    activePacksList.Items.Remove(pack);
                    activePacksList.Items.Insert(index + 1, pack);
                    activePacksList.SelectedItem = pack;
                }
            };

            applyButton.LeftMouseClick += (s, e) =>
            {
                manager.Game.Assets.ApplyResourcePacks(activePacksList.Items);
                Program.Restart();
            };

            // Daten laden

            AssetComponent assets = manager.Game.Assets;
            foreach (var item in assets.LoadedResourcePacks)
                loadedPacksList.Items.Add(item);

            foreach (var item in manager.Game.Assets.ActiveResourcePacks)
            {
                activePacksList.Items.Add(item);
                if (loadedPacksList.Items.Contains(item))
                    loadedPacksList.Items.Remove(item);
            }
        }
コード例 #32
0
ファイル: LoadScreen.cs プロジェクト: reicheltp/octoawesome
        public LoadScreen(ScreenComponent manager)
            : base(manager)
        {
            Manager = manager;

            Padding = new Border(0, 0, 0, 0);

            SetDefaultBackground();

            //Main Panel
            mainStack = new Grid(manager);
            mainStack.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 3 });
            mainStack.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 });
            mainStack.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Parts, Height = 1 });
            mainStack.Margin = Border.All(50);
            mainStack.HorizontalAlignment = HorizontalAlignment.Stretch;
            mainStack.VerticalAlignment = VerticalAlignment.Stretch;

            Controls.Add(mainStack);

            //Level Stack
            Listbox<IUniverse> levelList = new Listbox<IUniverse>(manager);
            levelList.Background = new BorderBrush(Color.White * 0.5f);
            levelList.VerticalAlignment = VerticalAlignment.Stretch;
            levelList.HorizontalAlignment = HorizontalAlignment.Stretch;
            levelList.Margin = Border.All(10);
            levelList.TemplateGenerator += (x) =>
            {
                return new Label(manager)
                {
                    Text = string.Format("{0} ({1})", x.Name, x.Seed),
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    Padding = Border.All(10),
                };
            };
            levelList.SelectedItemChanged += (s, e) =>
            {
                playButton.Enabled = e.NewItem != null;
                deleteButton.Enabled = e.NewItem != null;
            };
            mainStack.AddControl(levelList, 0, 0);

            //Sidebar
            Panel sidebar = new Panel(manager);
            sidebar.Padding = Border.All(20);
            sidebar.VerticalAlignment = VerticalAlignment.Stretch;
            sidebar.HorizontalAlignment = HorizontalAlignment.Stretch;
            sidebar.Background = new BorderBrush(Color.White * 0.5f);
            sidebar.Margin = Border.All(10);
            mainStack.AddControl(sidebar, 1, 0);

            //Universe Info
            Label l = new Label(manager);
            l.Text = " Placeholder ";
            l.VerticalAlignment = VerticalAlignment.Top;
            l.HorizontalAlignment = HorizontalAlignment.Left;
            sidebar.Controls.Add(l);

            //Buttons
            StackPanel buttonStack = new StackPanel(manager);
            buttonStack.VerticalAlignment = VerticalAlignment.Bottom;
            buttonStack.HorizontalAlignment = HorizontalAlignment.Stretch;
            sidebar.Controls.Add(buttonStack);

            //renameButton = getButton("Rename");
            //buttonStack.Controls.Add(renameButton);

            deleteButton = getButton("Delete");
            buttonStack.Controls.Add(deleteButton);
            deleteButton.LeftMouseClick += (s, e) =>
            {
                if (levelList.SelectedItem == null)
                    return;

                // Sicherstellen, dass universe nicht geladen ist
                if (ResourceManager.Instance.CurrentUniverse != null &&
                    ResourceManager.Instance.CurrentUniverse.Id == levelList.SelectedItem.Id)
                    return;

                ResourceManager.Instance.DeleteUniverse(levelList.SelectedItem.Id);
                levelList.Items.Remove(levelList.SelectedItem);
                levelList.SelectedItem = null;
                levelList.InvalidateDimensions();
            };

            createButton = getButton("Create");
            createButton.LeftMouseClick += (s, e) => manager.NavigateToScreen(new CreateUniverseScreen(manager));
            buttonStack.Controls.Add(createButton);

            playButton = getButton("Play");
            playButton.LeftMouseClick += (s, e) =>
            {
                if (levelList.SelectedItem == null)
                    return;

                manager.Player.RemovePlayer();
                manager.Game.Simulation.LoadGame(levelList.SelectedItem.Id);
                manager.Game.Player.InsertPlayer();
                manager.NavigateToScreen(new GameScreen(manager));
            };
            buttonStack.Controls.Add(playButton);

            foreach (var universe in ResourceManager.Instance.ListUniverses())
                levelList.Items.Add(universe);
        }
コード例 #33
0
ファイル: LoadScreen.cs プロジェクト: ManuelHu/octoawesome
        public LoadScreen(ScreenComponent manager)
            : base(manager)
        {
            Manager = manager;

            Padding = new Border(0, 0, 0, 0);

            Title = Languages.OctoClient.SelectUniverse;

            SetDefaultBackground();

            //Main Panel
            mainStack = new Grid(manager);
            mainStack.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 3 });
            mainStack.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 });
            mainStack.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Parts, Height = 1 });
            mainStack.Margin = Border.All(50);
            mainStack.HorizontalAlignment = HorizontalAlignment.Stretch;
            mainStack.VerticalAlignment = VerticalAlignment.Stretch;

            Controls.Add(mainStack);

            //Level Stack
            levelList = new Listbox<IUniverse>(manager);
            levelList.Background = new BorderBrush(Color.White * 0.5f);
            levelList.VerticalAlignment = VerticalAlignment.Stretch;
            levelList.HorizontalAlignment = HorizontalAlignment.Stretch;
            levelList.Margin = Border.All(10);
            levelList.SelectedItemBrush = new BorderBrush(Color.SaddleBrown * 0.7f);
            levelList.TemplateGenerator += (x) =>
            {
                return new Label(manager)
                {
                    Text = string.Format("{0} ({1})", x.Name, x.Seed),
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    Padding = Border.All(10),
                };
            };
            mainStack.AddControl(levelList, 0, 0);

            //Sidebar
            Panel sidebar = new Panel(manager);
            sidebar.Padding = Border.All(20);
            sidebar.VerticalAlignment = VerticalAlignment.Stretch;
            sidebar.HorizontalAlignment = HorizontalAlignment.Stretch;
            sidebar.Background = new BorderBrush(Color.White * 0.5f);
            sidebar.Margin = Border.All(10);
            mainStack.AddControl(sidebar, 1, 0);

            //Universe Info
            Label l = new Label(manager);
            l.Text = " Placeholder ";
            l.VerticalAlignment = VerticalAlignment.Top;
            l.HorizontalAlignment = HorizontalAlignment.Left;
            sidebar.Controls.Add(l);

            //Buttons
            StackPanel buttonStack = new StackPanel(manager);
            buttonStack.VerticalAlignment = VerticalAlignment.Bottom;
            buttonStack.HorizontalAlignment = HorizontalAlignment.Stretch;
            sidebar.Controls.Add(buttonStack);

            //renameButton = getButton("Rename");
            //buttonStack.Controls.Add(renameButton);

            deleteButton = GetButton(Languages.OctoClient.Delete);
            buttonStack.Controls.Add(deleteButton);
            deleteButton.LeftMouseClick += (s, e) =>
            {
                if (levelList.SelectedItem == null)
                {
                    MessageScreen msg = new MessageScreen(manager, Languages.OctoClient.Error, Languages.OctoClient.SelectUniverseFirst);
                    manager.NavigateToScreen(msg);

                    return;
                }

                // Sicherstellen, dass universe nicht geladen ist
                if (ResourceManager.Instance.CurrentUniverse != null &&
                    ResourceManager.Instance.CurrentUniverse.Id == levelList.SelectedItem.Id)
                    return;

                ResourceManager.Instance.DeleteUniverse(levelList.SelectedItem.Id);
                levelList.Items.Remove(levelList.SelectedItem);
                levelList.SelectedItem = null;
                levelList.InvalidateDimensions();
                SettingsManager.Set("LastUniverse", "");
            };

            createButton = GetButton(Languages.OctoClient.Create);
            createButton.LeftMouseClick += (s, e) => manager.NavigateToScreen(new CreateUniverseScreen(manager));
            buttonStack.Controls.Add(createButton);

            playButton = GetButton(Languages.OctoClient.Play);
            playButton.LeftMouseClick += (s, e) =>
            {
                if (levelList.SelectedItem == null)
                {
                    MessageScreen msg = new MessageScreen(manager, Languages.OctoClient.Error, Languages.OctoClient.SelectUniverseFirst);
                    manager.NavigateToScreen(msg);

                    return;
                }

                Play();
            };
            buttonStack.Controls.Add(playButton);

            foreach (var universe in ResourceManager.Instance.ListUniverses())
                levelList.Items.Add(universe);

            // Erstes Element auswählen, oder falls vorhanden das letzte gespielte Universum
            if (levelList.Items.Count >= 1)
                levelList.SelectedItem = levelList.Items[0];

            if (SettingsManager.KeyExists("LastUniverse") && SettingsManager.Get("LastUniverse") != null
                && SettingsManager.Get("LastUniverse") != "")
            {
                levelList.SelectedItem = levelList.Items.First(u => u.Id == Guid.Parse(SettingsManager.Get("LastUniverse")));
            }
        }
コード例 #34
0
ファイル: SplitScreen.cs プロジェクト: ManuelHu/monogameui
        public SplitScreen(BaseScreenComponent manager)
            : base(manager)
        {
            Background = new BorderBrush(Color.Gray);                       //Hintergrundfarbe festlegen

            Button backButton = Button.TextButton(manager, "Back");             //Neuen TextButton erzeugen
            backButton.HorizontalAlignment = HorizontalAlignment.Left;          //Links
            backButton.VerticalAlignment = VerticalAlignment.Top;               //Oben
            backButton.LeftMouseClick += (s, e) => { manager.NavigateBack(); }; //KlickEvent festlegen
            Controls.Add(backButton);                                           //Button zum Screen hinzufügen

            //ScrollContainer
            ScrollContainer scrollContainer = new ScrollContainer(manager)  //Neuen ScrollContainer erzeugen
            {
                VerticalAlignment = VerticalAlignment.Stretch,              // 100% Höhe
                HorizontalAlignment = HorizontalAlignment.Stretch           //100% Breite
            };
            Controls.Add(scrollContainer);                                  //ScrollContainer zum Root(Screen) hinzufügen

            //Stackpanel - SubControls werden Horizontal oder Vertikal gestackt
            StackPanel panel = new StackPanel(manager);                 //Neues Stackpanel erzeugen
            panel.VerticalAlignment = VerticalAlignment.Stretch;        //100% Höhe
            scrollContainer.Content = panel;                            //Ein Scroll Container kann nur ein Control beherbergen

            //Label
            Label label = new Label(manager) { Text = "Control Showcase" }; //Neues Label erzeugen
            panel.Controls.Add(label);                                      //Label zu Panel hinzufügen

            Button tB = Button.TextButton(manager, "TEST");
            tB.Background = new TextureBrush(LoadTexture2DFromFile("./test_texture_round.png", manager.GraphicsDevice), TextureBrushMode.Stretch);
            panel.Controls.Add(tB);

            //Button
            Button button = Button.TextButton(manager, "Dummy Button"); //Neuen TextButton erzeugen
            panel.Controls.Add(button);                                 //Button zu Panel hinzufügen

            //Progressbar
            ProgressBar pr = new ProgressBar(manager)                   //Neue ProgressBar erzeugen
            {
                Value = 99,                                             //Aktueller Wert
                Height = 20,                                            //Höhe
                Width = 200                                             //Breite
            };
            panel.Controls.Add(pr);                                     //ProgressBar zu Panel hinzufügen

            //ListBox
            Listbox<string> list = new Listbox<string>(manager);        //Neue ListBox erstellen
            list.TemplateGenerator = (item) =>                          //Template Generator festlegen
            {
                return new Label(manager) { Text = item };              //Control (Label) erstellen
            };
            panel.Controls.Add(list);                                   //Liste zu Panel hinzufügen

            list.Items.Add("Hallo");                                    //Items zur Liste hinzufügen
            list.Items.Add("Welt");                                     //...

            //Combobox
            Combobox<string> combobox = new Combobox<string>(manager)   //Neue Combobox erstellen
            {
                Height = 20,                                            //Höhe 20
                Width = 100                                             //Breite 100
            };
            combobox.TemplateGenerator = (item) =>                      //Template Generator festlegen
            {
                return new Label(manager) { Text = item };              //Control (Label) erstellen
            };
            panel.Controls.Add(combobox);                               //Combobox zu Panel  hinzufügen

            combobox.Items.Add("Combobox");                             //Items zu Combobox hinzufügen
            combobox.Items.Add("Item");
            combobox.Items.Add("Hallo");

            Button clearCombobox = Button.TextButton(manager, "Clear Combobox");
            clearCombobox.LeftMouseClick += (s, e) => {
                combobox.Items.Clear();
                list.Items.Clear();
            };
            panel.Controls.Add(clearCombobox);

            //Slider Value Label
            Label labelSliderHorizontal = new Label(manager);

            //Horizontaler Slider
            Slider sliderHorizontal = new Slider(manager)
            {
                Width = 150,
                Height = 20,
            };
            sliderHorizontal.ValueChanged += (value) => { labelSliderHorizontal.Text = "Value: " + value; }; //Event on Value Changed
            panel.Controls.Add(sliderHorizontal);
            labelSliderHorizontal.Text = "Value: " + sliderHorizontal.Value;                                 //Set Text initially
            panel.Controls.Add(labelSliderHorizontal);

            //Slider Value Label
            Label labelSliderVertical = new Label(manager);

            //Vertikaler Slider
            Slider sliderVertical = new Slider(manager)
            {
                Range = 100,
                Height = 200,
                Width = 20,
                Orientation = Orientation.Vertical
            };
            sliderVertical.ValueChanged += (value) => { labelSliderVertical.Text = "Value: " + value; };
            panel.Controls.Add(sliderVertical);
            labelSliderVertical.Text = "Value: " + sliderVertical.Value;
            panel.Controls.Add(labelSliderVertical);

            Checkbox checkbox = new Checkbox(manager);
            panel.Controls.Add(checkbox);

            //Textbox
            textbox = new Textbox(manager)                      //Neue TextBox erzeugen
            {
                Background = new BorderBrush(Color.LightGray),          //Festlegen eines Backgrounds für ein Control
                HorizontalAlignment = HorizontalAlignment.Stretch,          //100% Breite
                Text = "TEXTBOX!",                                      //Voreingestellter text
                MinWidth = 100                                          //Eine Textbox kann ihre Größe automatisch anpassen
            };

            Button clearTextbox = Button.TextButton(manager, "Clear Textbox");
            clearTextbox.LeftMouseClick += (s, e) =>
            {
                textbox.SelectionStart = 0;
                textbox.Text = "";
            };

            Button disableControls = Button.TextButton(manager, "Toggle Controls disabled");
            disableControls.LeftMouseClick += (s, e) =>
            {
                foreach (var c in panel.Controls)
                {
                    c.Enabled = !c.Enabled;
                }
            };
            panel.Controls.Add(clearTextbox);
            panel.Controls.Add(textbox);                                //Textbox zu Panel hinzufügen
            panel.Controls.Add(disableControls);
        }
コード例 #35
0
 bool IsDeniedMultipleSelection(Item item, Listbox listbox)
 {
     if(item == null)
      {
     return true;
      }
      if(AllowMultipleSelection)
      {
     return false;
      }
      foreach(Sitecore.Web.UI.HtmlControls.ListItem li in listbox.Controls)
      {
         string[] pair = li.Value.Split(new char[]{'|'});
         if(pair.Length < 2) continue;
     if(pair[1] == item.ID.ToString())
     {
        return true;
     }
      }
      return false;
 }
コード例 #36
0
        protected override void OnLoad(EventArgs args)
        {
            if (!Sitecore.Context.ClientPage.IsEvent)
             {
            SetProperties();
            GridPanel gridPanel = new GridPanel();
            Controls.Add(gridPanel);
            gridPanel.Columns = 4;
            GetControlAttributes();

            foreach (string text2 in base.Attributes.Keys)
            {
               gridPanel.Attributes.Add(text2, base.Attributes[text2]);
            }

            gridPanel.Style["margin"] = "0px 0px 4px 0px";
            SetViewStateString("ID", ID);
            Sitecore.Web.UI.HtmlControls.Literal literal = new Sitecore.Web.UI.HtmlControls.Literal("All");
            literal.Class = ("scContentControlMultilistCaption");

            gridPanel.Controls.Add(literal);
            gridPanel.SetExtensibleProperty(literal, "Width", "50%");
            gridPanel.SetExtensibleProperty(literal, "Row.Height", "20px");

            LiteralControl spacer = new LiteralControl(Images.GetSpacer(24, 1));
            gridPanel.Controls.Add(spacer);
            gridPanel.SetExtensibleProperty(spacer, "Width", "24px");

            literal = new Sitecore.Web.UI.HtmlControls.Literal("Selected");
            literal.Class = "scContentControlMultilistCaption";

            gridPanel.Controls.Add(literal);
            gridPanel.SetExtensibleProperty(literal, "Width", "50%");

            spacer = new LiteralControl(Images.GetSpacer(24, 1));
            gridPanel.Controls.Add(spacer);
            gridPanel.SetExtensibleProperty(spacer, "Width", "24px");

            Scrollbox scrollbox = new Scrollbox();
            scrollbox.ID = GetUniqueID("S");

            gridPanel.Controls.Add(scrollbox);
            scrollbox.Style["border"] = "3px window-inset";
            gridPanel.SetExtensibleProperty(scrollbox, "rowspan", "2");

            DataTreeview dataTreeView = new DataTreeview();
            dataTreeView.ID = ID + "_all";
            scrollbox.Controls.Add(dataTreeView);
            dataTreeView.DblClick = ID + ".Add";

            ImageBuilder builderRight = new ImageBuilder();
            builderRight.Src = "Applications/16x16/nav_right_blue.png";
            builderRight.ID = ID + "_right";
            builderRight.Width = 0x10;
            builderRight.Height = 0x10;
            builderRight.Margin = "2";
            builderRight.OnClick = Sitecore.Context.ClientPage.GetClientEvent(ID + ".Add");

            ImageBuilder builderLeft = new ImageBuilder();
            builderLeft.Src = "Applications/16x16/nav_left_blue.png";
            builderLeft.ID = ID + "_left";
            builderLeft.Width = 0x10;
            builderLeft.Height = 0x10;
            builderLeft.Margin = "2";
            builderLeft.OnClick = Sitecore.Context.ClientPage.GetClientEvent(ID + ".Remove");

            LiteralControl literalControl = new LiteralControl(builderRight.ToString() + "<br/>" + builderLeft.ToString());
            gridPanel.Controls.Add(literalControl);
            gridPanel.SetExtensibleProperty(literalControl, "Width", "30");
            gridPanel.SetExtensibleProperty(literalControl, "Align", "center");
            gridPanel.SetExtensibleProperty(literalControl, "VAlign", "top");
            gridPanel.SetExtensibleProperty(literalControl, "rowspan", "2");

            Sitecore.Web.UI.HtmlControls.Listbox listbox = new Listbox();
                listBox = listbox;
            gridPanel.SetExtensibleProperty(listbox, "VAlign", "top");
            gridPanel.SetExtensibleProperty(listbox, "Height", "100%");

            gridPanel.Controls.Add(listbox);
            listbox.ID = ID + "_selected";
            listbox.DblClick = ID + ".Remove";
            listbox.Style["width"] = "100%";
            listbox.Size = "10";
            listbox.Attributes["onchange"] = "javascript:document.getElementById('" + this.ID + "_help').innerHTML=this.selectedIndex>=0?this.options[this.selectedIndex].innerHTML:''";
            listbox.Attributes["class"] = "scContentControlMultilistBox";

            dataTreeView.Disabled = ReadOnly;
            listbox.Disabled = ReadOnly;

            ImageBuilder builderUp = new ImageBuilder();
            builderUp.Src = "Applications/16x16/nav_up_blue.png";
            builderUp.ID = ID + "_up";
            builderUp.Width = 0x10;
            builderUp.Height = 0x10;
            builderUp.Margin = "2px";
            builderUp.OnClick = Sitecore.Context.ClientPage.GetClientEvent(ID + ".Up");

            ImageBuilder builderDown = new ImageBuilder();
            builderDown.Src = "Applications/16x16/nav_down_blue.png";
            builderDown.ID = ID + "_down";
            builderDown.Width = 0x10;
            builderDown.Height = 0x10;
            builderDown.Margin = "2";
            builderDown.OnClick = Sitecore.Context.ClientPage.GetClientEvent(ID + ".Down");

            literalControl = new LiteralControl(builderUp.ToString() + "<br/>" + builderDown.ToString());
            gridPanel.Controls.Add(literalControl);
            gridPanel.SetExtensibleProperty(literalControl, "Width", "30");
            gridPanel.SetExtensibleProperty(literalControl, "Align", "center");
            gridPanel.SetExtensibleProperty(literalControl, "VAlign", "top");
            gridPanel.SetExtensibleProperty(literalControl, "rowspan", "2");
            gridPanel.Controls.Add(new LiteralControl("<div style=\"border:1px solid #999999;font:8pt tahoma;padding:2px;margin:4px 0px 4px 0px;height:14px\" id=\"" + this.ID + "_help\"></div>"));

            DataContext treeContext = new DataContext();
            gridPanel.Controls.Add(treeContext);
            treeContext.ID = GetUniqueID("D");
            treeContext.Filter = FormTemplateFilterForDisplay();
            dataTreeView.DataContext = treeContext.ID;
            treeContext.DataViewName = "Master";
            if (!string.IsNullOrEmpty(this.SourceDatabaseName))
            {
               treeContext.Parameters = "databasename=" + this.SourceDatabaseName;
            }
            treeContext.Root = DataSource;
            dataTreeView.EnableEvents();

            listbox.Size = "10";
            gridPanel.Fixed = true;
            dataTreeView.AutoUpdateDataContext = true;
            dataTreeView.ShowRoot = true;
            listbox.Attributes["class"] = "scContentControlMultilistBox";

            gridPanel.SetExtensibleProperty(scrollbox, "Height", "100%");
            RestoreState();
             }
             base.OnLoad(args);
        }
コード例 #37
0
		private bool IsDeniedMultipleSelection(Item item, Listbox listbox)
		{
			Assert.ArgumentNotNull(listbox, "listbox");
			if (item == null)
			{
				return true;
			}
			if (!this.AllowMultipleSelection)
			{
				foreach (ListItem item2 in listbox.Controls)
				{
					string[] strArray = item2.Value.Split(new char[] { '|' });
					if ((strArray.Length >= 2) && (strArray[1] == item.ID.ToString()))
					{
						return true;
					}
				}
			}
			return false;
		}
コード例 #38
0
ファイル: Program.cs プロジェクト: ianlee74/Gadgetab
        private void ZombieTwitForm()
        {
            var tweets = new[]{
                                    @"@zombieHunter Zombies are coming!"
                                    , @"@zombieHunter Zombies are getting closer!"
                                    , @"@zombieHunter THEY'RE HERE!!!"
                                    , @"@zombieHunter Send the Gadgets!!!"
                                    , @"@zombieHunter Tell my wife and kids..."
                                    , @"@zombieHunter ...I'll eat them later!"
                                };

            var frm = new Form("zombie twit");

            // Add panel
            var pnl = new Skewworks.Tinkr.Controls.Panel("pnl1", 0, 0, 800, 480);
            pnl.BackgroundImage = Resources.GetBitmap(Resources.BitmapResources.Zombies);
            frm.AddControl(pnl);

            // Add the app bar.
            pnl.AddControl(BuildAppBar(frm.Name));

            // Add a title.
            var title = new Label("lblTitle", "Zombie Twit", _fntHuge, frm.Width / 2 - 100, 50) { Color = Gadgeteer.Color.Yellow };
            pnl.AddControl(title);

            // Add a listbox
            var lb = new Listbox("lb1", _fntArialBold11, frm.Width / 2 - 200, frm.Height / 2 - 100, 400, 200, null);
            pnl.AddControl(lb);

            TinkrCore.ActiveContainer = frm;

            byte lastTweet = 0;
            var timer = new GT.Timer(2000);
            timer.Tick += timer1 =>
                              {
                                  if(lastTweet >= tweets.Length)
                                  {
                                      timer.Stop();
                                      return;
                                  }
                                  //lb.InsertAt(tweets[lastTweet++], 1);
                                  lb.AddItem(tweets[lastTweet++]);
                              };
            timer.Start();
        }
コード例 #39
0
		// This method is the only method that differs from Sitecore's
		// TreeList class
		protected override void OnLoad(EventArgs args)
		{
			Assert.ArgumentNotNull(args, "args");
			if (!Sitecore.Context.ClientPage.IsEvent)
			{
				Database contentDatabase = Sitecore.Context.ContentDatabase;
				if (!string.IsNullOrEmpty(this.DatabaseName))
				{
					contentDatabase = Factory.GetDatabase(this.DatabaseName);
				}

				this.SetProperties();
				GridPanel child = new GridPanel();
				this.Controls.Add(child);
				child.Columns = 4;
				this.GetControlAttributes();
				foreach (string str in base.Attributes.Keys)
				{
					child.Attributes.Add(str, base.Attributes[str]);
				}
				child.Style["margin"] = "0px 0px 4px 0px";
				base.SetViewStateString("ID", this.ID);
				Literal literal = new Literal("All");
				literal.Class = "scContentControlMultilistCaption";
				child.Controls.Add(literal);
				child.SetExtensibleProperty(literal, "Width", "50%");
				child.SetExtensibleProperty(literal, "Row.Height", "20px");
				LiteralControl control = new LiteralControl(Images.GetSpacer(0x18, 1));
				child.Controls.Add(control);
				child.SetExtensibleProperty(control, "Width", "24px");
				literal = new Literal("Selected");
				literal.Class = "scContentControlMultilistCaption";
				child.Controls.Add(literal);
				child.SetExtensibleProperty(literal, "Width", "50%");
				control = new LiteralControl(Images.GetSpacer(0x18, 1));
				child.Controls.Add(control);
				child.SetExtensibleProperty(control, "Width", "24px");
				Scrollbox scrollbox = new Scrollbox();
				scrollbox.ID = Sitecore.Web.UI.HtmlControls.Control.GetUniqueID("S");
				child.Controls.Add(scrollbox);
				if (!UIUtil.IsIE())
				{
					scrollbox.Padding = "0px";
				}
				scrollbox.Style["border"] = "3px window-inset";
				child.SetExtensibleProperty(scrollbox, "rowspan", "2");
				child.SetExtensibleProperty(scrollbox, "VAlign", "top");
				// Instantiate the MultiTreeview rather than TreeviewEx
				MultiRootTreeview ex = new MultiRootTreeview();
				// Set the ParentItem of the treeview to the current item
				// This allows the treeview to have a 'context' of where 
				// we currently are in the content tree
				Item parentItem = contentDatabase.GetItem(ItemID);
				ex.ParentItem = parentItem;
				ex.ID = this.ID + "_all";
				if (!string.IsNullOrEmpty(AncestorTemplateDatasource))
				{
					Item parent = parentItem;
					while (parent != null && String.Compare(parent.TemplateID.ToString(), AncestorTemplateDatasource, StringComparison.OrdinalIgnoreCase) != 0)
					{
						parent = parent.Parent;
					}
					ex.MultiTrees.Add(2, parent);
				}
				else if (DataSources.Count > 0)
				{
					foreach (KeyValuePair<int, string> kvp in DataSources)
					{
						if (!string.IsNullOrEmpty(kvp.Value))
						{
							if (kvp.Value == ".")
							{
								ex.MultiTrees.Add(kvp.Key, parentItem);
							}
							else if (kvp.Value.StartsWith("."))
							{
								string path = kvp.Value.Replace(".", parentItem.Paths.FullPath);
								ex.MultiTrees.Add(kvp.Key, contentDatabase.GetItem(path));
							}
							else
							{
								ex.MultiTrees.Add(kvp.Key, contentDatabase.GetItem(kvp.Value));
							}
						}
					}
				}
				scrollbox.Controls.Add(ex);
				ex.DblClick = this.ID + ".Add";
				ex.AllowDragging = false;
				ImageBuilder builder = new ImageBuilder();
				builder.Src = "Applications/16x16/nav_right_blue.png";
				builder.ID = this.ID + "_right";
				builder.Width = 0x10;
				builder.Height = 0x10;
				builder.Margin = UIUtil.IsIE() ? "2px" : "2px 0px 2px 2px";
				builder.OnClick = Sitecore.Context.ClientPage.GetClientEvent(this.ID + ".Add");
				ImageBuilder builder2 = new ImageBuilder();
				builder2.Src = "Applications/16x16/nav_left_blue.png";
				builder2.ID = this.ID + "_left";
				builder2.Width = 0x10;
				builder2.Height = 0x10;
				builder2.Margin = UIUtil.IsIE() ? "2px" : "2px 0px 2px 2px";
				builder2.OnClick = Sitecore.Context.ClientPage.GetClientEvent(this.ID + ".Remove");
				LiteralControl control2 = new LiteralControl(builder + "<br/>" + builder2);
				child.Controls.Add(control2);
				child.SetExtensibleProperty(control2, "Width", "30");
				child.SetExtensibleProperty(control2, "Align", "center");
				child.SetExtensibleProperty(control2, "VAlign", "top");
				child.SetExtensibleProperty(control2, "rowspan", "2");
				Listbox listbox = new Listbox();
				child.Controls.Add(listbox);
				child.SetExtensibleProperty(listbox, "VAlign", "top");
				child.SetExtensibleProperty(listbox, "Height", "100%");
				this._listBox = listbox;
				listbox.ID = this.ID + "_selected";
				listbox.DblClick = this.ID + ".Remove";
				listbox.Style["width"] = "100%";
				listbox.Size = "10";
				listbox.Attributes["onchange"] = "javascript:document.getElementById('" + this.ID + "_help').innerHTML=this.selectedIndex>=0?this.options[this.selectedIndex].innerHTML:''";
				listbox.Attributes["class"] = "scContentControlMultilistBox";
				ex.Enabled = !this.ReadOnly;
				listbox.Disabled = this.ReadOnly;
				ImageBuilder builder3 = new ImageBuilder();
				builder3.Src = "Applications/16x16/nav_up_blue.png";
				builder3.ID = this.ID + "_up";
				builder3.Width = 0x10;
				builder3.Height = 0x10;
				builder3.Margin = "2px";
				builder3.OnClick = Sitecore.Context.ClientPage.GetClientEvent(this.ID + ".Up");
				ImageBuilder builder4 = new ImageBuilder();
				builder4.Src = "Applications/16x16/nav_down_blue.png";
				builder4.ID = this.ID + "_down";
				builder4.Width = 0x10;
				builder4.Height = 0x10;
				builder4.Margin = "2px";
				builder4.OnClick = Sitecore.Context.ClientPage.GetClientEvent(this.ID + ".Down");
				control2 = new LiteralControl(builder3 + "<br/>" + builder4);
				child.Controls.Add(control2);
				child.SetExtensibleProperty(control2, "Width", "30");
				child.SetExtensibleProperty(control2, "Align", "center");
				child.SetExtensibleProperty(control2, "VAlign", "top");
				child.SetExtensibleProperty(control2, "rowspan", "2");
				child.Controls.Add(new LiteralControl("<div style=\"border:1px solid #999999;font:8pt tahoma;padding:2px;margin:4px 0px 4px 0px;height:14px\" id=\"" + this.ID + "_help\"></div>"));
				DataContext context = new DataContext();
				child.Controls.Add(context);
				context.ID = Sitecore.Web.UI.HtmlControls.Control.GetUniqueID("D");
				context.Filter = this.FormTemplateFilterForDisplay();
				ex.DataContext = context.ID;
				context.DataViewName = "Master";
				if (!string.IsNullOrEmpty(this.DatabaseName))
				{
					context.Parameters = "databasename=" + this.DatabaseName;
				}
				context.Root = this.DataSource;
				child.Fixed = true;
				ex.ShowRoot = true;
				child.SetExtensibleProperty(scrollbox, "Height", "100%");
				this.RestoreState();
			}
			base.OnLoad(args);
		}