Beispiel #1
0
 private void EnsureInput()
 {
     if (this._elmDefaultInput == null)
     {
         this._elmDefaultInput = new Input();
         this._elmDefaultInput.Type = "text";
         Utility.SetImeMode(_elmDefaultInput, Properties.ImeEnabled);
     }
 }
Beispiel #2
0
 public override void Dispose()
 {
     base.Dispose();
     _elmDefaultInput = null;
 }
Beispiel #3
0
 public override void Dispose()
 {
     base.Dispose();
     _elmMedium = null;
     _elmMediumCheckboxInput = null;
     _elmMediumLabel = null;
     _elmSmall = null;
     _elmSmallCheckboxInput = null;
 }
Beispiel #4
0
        internal override void AttachDOMElementsForDisplayMode(string displayMode)
        {
            Input elm = (Input)Browser.Document.GetById(Id);
            this.StoreElementForDisplayMode(elm, displayMode);

            switch (displayMode)
            {
                case "Medium":
                    _elmDefaultInput = elm;
                    break;
            }
        }
Beispiel #5
0
        internal override void AttachDOMElementsForDisplayMode(string displayMode)
        {
            Span elm = (Span)Browser.Document.GetById(Id + "-" + displayMode);
            this.StoreElementForDisplayMode(elm, displayMode);

            // Only do hookup for non-menu display modes for now
            switch (displayMode)
            {
                case "Medium":
                    _elmMedium = elm;
                    _elmMediumCheckboxInput = (Input)elm.FirstChild;
                    _elmMediumLabel = (MSLabel)elm.ChildNodes[1];
                    break;
                case "Small":
                    _elmSmall = elm;
                    _elmSmallCheckboxInput = (Input)elm.FirstChild;
                    break;
            }
        }
Beispiel #6
0
        protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode)
        {
            string alt = string.IsNullOrEmpty(Properties.Alt) ?
                        Properties.LabelText : Properties.Alt;
            alt = CUIUtility.SafeString(alt);

            switch (displayMode)
            {
                case "Small":
                    // Create DOM elements
                    _elmSmall = new Span();
                    _elmSmall.ClassName = "ms-cui-cbx";
                    _elmSmall.SetAttribute("mscui:controltype", ControlType);

                    _elmSmallCheckboxInput = new Input();
                    _elmSmallCheckboxInput.Type = "checkbox";
                    _elmSmallCheckboxInput.ClassName = "ms-cui-cbx-input";
                    _elmSmallCheckboxInput.Id = _id + "-Small-checkbox";
                    if (string.IsNullOrEmpty(Properties.ToolTipTitle))
                    {
                        _elmSmallCheckboxInput.Title = alt;
                    }

                    _elmSmallCheckboxInput.SetAttribute("role", AriaRole);
                    Utility.SetAriaTooltipProperties(Properties, _elmSmallCheckboxInput);

                    // Set up event handlers
                    AttachEvents(_elmSmallCheckboxInput, null);

                    //Build DOM Structure
                    _elmSmall.AppendChild(_elmSmallCheckboxInput);

                    return _elmSmall;
                case "Medium":
                    // Create DOM elements
                    _elmMedium = new Span();
                    _elmMedium.ClassName = "ms-cui-cbx";
                    _elmMedium.SetAttribute("mscui:controltype", ControlType);

                    _elmMediumCheckboxInput = new Input();
                    _elmMediumCheckboxInput.Type = "checkbox";
                    _elmMediumCheckboxInput.ClassName = "ms-cui-cbx-input";
                    _elmMediumCheckboxInput.Id = _id + "-Medium-checkbox";
                    if (string.IsNullOrEmpty(Properties.ToolTipTitle))
                    {
                        _elmMediumCheckboxInput.Title = alt;

                    }
                    _elmMediumCheckboxInput.SetAttribute("role", AriaRole);
                    Utility.SetAriaTooltipProperties(Properties, _elmMediumCheckboxInput);

                    bool hasLabel = false;
                    if (!string.IsNullOrEmpty(Properties.LabelText))
                    {
                        _elmMediumLabel = new MSLabel();
                        if (BrowserUtility.InternetExplorer7)
                        {
                            _elmMediumLabel.SetAttribute("htmlFor", _id + "-Medium-checkbox");
                        }
                        else
                        {
                            _elmMediumLabel.SetAttribute("for", _id + "-Medium-checkbox");
                        }
                        UIUtility.SetInnerText(_elmMediumLabel, Properties.LabelText);
                        hasLabel = true;
                    }

                    // Set up event handlers
                    AttachEvents(_elmMediumCheckboxInput, _elmMediumLabel);

                    // Build DOM Structure
                    _elmMedium.AppendChild(_elmMediumCheckboxInput);
                    if (hasLabel)
                        _elmMedium.AppendChild(_elmMediumLabel);

                    return _elmMedium;
                default:
                    EnsureValidDisplayMode(displayMode);
                    return null;
            }
        }
Beispiel #7
0
 public override void Dispose()
 {
     base.Dispose();
     _elmMedium = null;
     _elmMediumArwImg = null;
     _elmMediumArwImgCont = null;
     _elmMediumBtnA = null;
     _elmMediumInput = null;
 }
Beispiel #8
0
        protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode)
        {
            switch (displayMode)
            {
                case "Medium":
                    string alt = CUIUtility.SafeString(CBProperties.Alt);
                    string altArrow = CUIUtility.SafeString(CBProperties.AltArrow);

                    // Top Level Element
                    _elmMedium = new Span();
                    _elmMedium.ClassName = "ms-cui-cb";
                    _elmMedium.SetAttribute("mscui:controltype", ControlType);

                    // Input Element
                    _elmMediumInput = new Input();
                    _elmMediumInput.SetAttribute("name", CBProperties.Command);
                    _elmMediumInput.Type = "text";
                    _elmMediumInput.Style.Width = CBProperties.Width;
                    _elmMediumInput.ClassName = "ms-cui-cb-input";
                    _elmMediumInput.SetAttribute("autocomplete", "off");
                    _elmMediumInput.Id = CBProperties.Id;
                    if (string.IsNullOrEmpty(Properties.ToolTipTitle))
                        _elmMediumInput.Title = alt;
                    Utility.SetImeMode(_elmMediumInput, ((ComboBoxProperties)Properties).ImeEnabled);

                    string itemId = (string)StateProperties[ComboBoxCommandProperties.SelectedItemId];
                    if (string.IsNullOrEmpty(itemId))
                        itemId = CBProperties.InitialItem;
                    if (!string.IsNullOrEmpty(itemId))
                        SelectMenuItemById(itemId);

                    Utility.SetAriaTooltipProperties(Properties, _elmMediumInput);

                    // Arrow Button Element
                    _elmMediumBtnA = new Anchor();
                    Utility.EnsureCSSClassOnElement(_elmMediumBtnA, "ms-cui-dd-arrow-button");
                    Utility.NoOpLink(_elmMediumBtnA);

                    _elmMediumBtnA.TabIndex = -1; // Only the input box should be tab-able
                    _elmMediumBtnA.SetAttribute("aria-haspopup", "true");

                    _elmMediumArwImg = new Image();

                    _elmMediumArwImgCont = Utility.CreateClusteredImageContainerNew(
                                                                            ImgContainerSize.Size5by3,
                                                                            Root.Properties.ImageDownArrow,
                                                                            Root.Properties.ImageDownArrowClass,
                                                                            _elmMediumArwImg,
                                                                            true,
                                                                            false,
                                                                            Root.Properties.ImageDownArrowTop,
                                                                            Root.Properties.ImageDownArrowLeft
                                                                            );

                    if (string.IsNullOrEmpty(Properties.ToolTipTitle))
                    {
                        _elmMediumArwImg.Alt = altArrow;
                        _elmMediumBtnA.Title = altArrow;
                    }

                    // Set up event handlers for the Drop Down Arrow Button
                    AttachEventsForDisplayMode("Medium");

                    // Build DOM Structure
                    _elmMedium.AppendChild(_elmMediumInput);
                    _elmMedium.AppendChild(_elmMediumBtnA);

                    _elmMediumBtnA.AppendChild(_elmMediumArwImgCont);
                    return _elmMedium;
                default:
                    EnsureValidDisplayMode(displayMode);
                    return null;
            }
        }
Beispiel #9
0
 public override void Dispose()
 {
     base.Dispose();
     _downArwImg = null;
     _downArwImgCont = null;
     _upArwImg = null;
     _upArwImgCont = null;
     _elmDefault = null;
     _elmDefaultArwBox = null;
     _elmDefaultDownArw = null;
     _elmDefaultInput = null;
     _elmDefaultUpArw = null;
 }
Beispiel #10
0
        internal override void AttachDOMElementsForDisplayMode(string displayMode)
        {
            Span elm = (Span)Browser.Document.GetById(Id + "-" + displayMode);
            StoreElementForDisplayMode(elm, displayMode);

            // If we are attaching, we clear the initial item since this is dynamically
            // generated from a DOM element from a subitem.  This will cause the new
            // DOM element to be generated the first time that this is queried.
            StateProperties[DropDownCommandProperties.SelectedItemId] = "";

            // Only do hookup for non-menu display modes for now
            switch (displayMode)
            {
                case "Medium":
                    _elmMedium = elm;
                    _elmMediumInput = (Input)_elmMedium.ChildNodes[0];
                    _elmMediumBtnA = (Anchor)_elmMedium.ChildNodes[1];
                    _elmMediumArwImgCont = (Span)_elmMediumBtnA.ChildNodes[0];
                    _elmMediumArwImg = (Image)_elmMediumArwImgCont.ChildNodes[0];

                    Utility.SetUnselectable(_elmMediumInput, false, false);
                    break;
            }
        }
Beispiel #11
0
        protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode)
        {
            switch (displayMode)
            {
                case "Medium":
                    _elmDefault = new Span();
                    _elmDefault.ClassName = "ms-cui-spn";
                    _elmDefault.SetAttribute("mscui:controltype", ControlType);

                    _elmDefaultInput = new Input();
                    _elmDefaultInput.ClassName = "ms-cui-spn-txtbx";
                    _elmDefaultInput.Id = Id;
                    _elmDefaultInput.SetAttribute("role", "textbox");

                    Utility.SetAriaTooltipProperties(Properties, _elmDefaultInput);
                    Utility.SetImeMode(_elmDefaultInput, Properties.ImeEnabled);

                    _elmDefaultArwBox = new Span();
                    _elmDefaultArwBox.ClassName = "ms-cui-spn-arwbx";

                    _elmDefaultUpArw = new Anchor();
                    _elmDefaultUpArw.ClassName = "ms-cui-spn-btnup";
                    _elmDefaultUpArw.SetAttribute("role", "spinbutton");

                    _elmDefaultDownArw = new Anchor();
                    _elmDefaultDownArw.ClassName = "ms-cui-spn-btndown";
                    _elmDefaultDownArw.SetAttribute("role", "spinbutton");

                    _upArwImg = new Image();
                    _upArwImg.Alt = "";
                    _upArwImgCont = Utility.CreateClusteredImageContainerNew(
                                                                    ImgContainerSize.Size5by3,
                                                                    Root.Properties.ImageUpArrow,
                                                                    Root.Properties.ImageUpArrowClass,
                                                                    _upArwImg,
                                                                    true,
                                                                    false,
                                                                    Root.Properties.ImageUpArrowTop,
                                                                    Root.Properties.ImageUpArrowLeft);
                                                                    
                    
                    Utility.EnsureCSSClassOnElement(_upArwImgCont, "ms-cui-spn-imgcnt");
                    _elmDefaultUpArw.Title = CUIUtility.SafeString(Properties.AltUpArrow);

                    _downArwImg = new Image();
                    _downArwImg.Alt = "";
                    _downArwImgCont = Utility.CreateClusteredImageContainerNew(
                                                                      ImgContainerSize.Size5by3,
                                                                      Root.Properties.ImageDownArrow,
                                                                      Root.Properties.ImageDownArrowClass,
                                                                      _downArwImg,
                                                                      true,
                                                                      false,
                                                                      Root.Properties.ImageDownArrowTop,
                                                                      Root.Properties.ImageDownArrowLeft);

                    Utility.EnsureCSSClassOnElement(_downArwImgCont, "ms-cui-spn-imgcnt");
                    _elmDefaultDownArw.Title = CUIUtility.SafeString(Properties.AltDownArrow);

                    // Set up event handlers
                    AttachEventsForDisplayMode(displayMode);

                    // Build DOM Structure
                    _elmDefault.AppendChild(_elmDefaultInput);
                    _elmDefault.AppendChild(_elmDefaultArwBox);
                    _elmDefaultArwBox.AppendChild(_elmDefaultUpArw);
                    _elmDefaultArwBox.AppendChild(_elmDefaultDownArw);
                    _elmDefaultUpArw.AppendChild(_upArwImgCont);
                    _elmDefaultDownArw.AppendChild(_downArwImgCont);

                    return _elmDefault;
                default:
                    EnsureValidDisplayMode(displayMode);
                    return null;
            }
        }
Beispiel #12
0
        internal override void AttachDOMElementsForDisplayMode(string displayMode)
        {
            Span elm = (Span)Browser.Document.GetById(Id + "-" + displayMode);
            StoreElementForDisplayMode(elm, displayMode);

            switch (displayMode)
            {
                case "Medium":
                    _elmDefault = elm;
                    _elmDefaultInput = (Input)_elmDefault.ChildNodes[0];
                    _elmDefaultArwBox = (Span)_elmDefault.ChildNodes[1];
                    _elmDefaultUpArw = (Anchor)_elmDefaultArwBox.ChildNodes[0];
                    _elmDefaultDownArw = (Anchor)_elmDefaultArwBox.ChildNodes[1];
                    _upArwImgCont = (Span)_elmDefaultUpArw.ChildNodes[0];
                    _downArwImgCont = (Span)_elmDefaultDownArw.ChildNodes[0];
                    _upArwImg = (Image)_upArwImgCont.ChildNodes[0];
                    _downArwImg = (Image)_downArwImgCont.ChildNodes[0];
                    break;
            }
        }
Beispiel #13
0
        private void ToggleSelectionState(Input cbx, int itemId, bool select)
        {
            // Get parent table row to update CSS classes
            TableRow pRow = (TableRow)cbx.ParentNode.ParentNode;

            if (select)
            {
                _selectionCount++;
                _itemSelected[itemId] = true;
                Utility.EnsureCSSClassOnElement(pRow, "s4-itm-selected");
            }
            else
            {
                _selectionCount--;
                _itemSelected[itemId] = false;
                Utility.RemoveCSSClassFromElement(pRow, "s4-itm-selected");
            }
        }
Beispiel #14
0
        public TestPageComponent()
        {
            _selectionCount = 0;
            _itemSelected = new Dictionary<int, bool>();
            _itemCbxCache = new Dictionary<int, Input>();
            _listViewTable = (Table)Browser.Document.GetById("onetidDoclibViewTbl0");

            _selectAllCheckbox = (Input)Browser.Document.GetById("selectAllCbx");
            _selectAllCheckbox.Click += OnSelectAllCbxClick;

            for (int i = 1; i < 5; i++)
            {
                // Set that each item is unselected and add event handler
                _itemSelected[i] = false;

                string cbxName = "item" + i.ToString() + "cbx";
                Input itemcbx = (Input)Browser.Document.GetById(cbxName);
                itemcbx.Click += OnItemCbxClick;
                _itemCbxCache[i] = itemcbx;
            }
        }
Beispiel #15
0
        public EventLinkPage()
        {
            var text = new Div() { Text = "Server Address:" };
            var textbox = new Input() { Value="elipc:4040" };
            var div = new Div();
            div.Add(text);
            div.Add(textbox);
            Browser.Document.Body.Add(div);

            // Conventional DOM interaction
            var jsonButton = new Button { InnerHtml = "Test JSON..." };
            jsonButton.Click += e =>
            {
                MemoryStream st = new MemoryStream();
                PrincipalObject obj = new PrincipalObject() { Sid = "sa", Id = "eli" };
                Console.WriteLine(obj);

                JsonPayloadWriter w = new JsonPayloadWriter(st);
                var pl = new ObjectPayload(Guid.NewGuid(), obj, Guid.NewGuid(), "ObjectName");
                Console.WriteLine(pl);
                w.Write(string.Empty, pl);
                StreamReader sr = new StreamReader(st);
                string output = sr.ReadToEnd();
                Console.WriteLine(output);
                return;



                //DUMMY TEST
                //string jsont = "{ \"ChannelName\": \"test\" }";
                //JsonPayloadReader jsr = new JsonPayloadReader(jsont);
                //Console.WriteLine(jsr.ReadString("ChannelName"));

                string ns = "namespace1";
                string subscriptionId = "1234";
                Guid clientId = Guid.NewGuid();
                Guid parentId = Guid.NewGuid();
                Guid objectId = Guid.NewGuid();

                Payload payload = new ClientConnectPayload(subscriptionId, clientId, ns, NamespaceLifetime.ServerInstance);
                ETag eTag = new ETag(clientId, 2);
                string json = WriteToJson(payload);
                Console.WriteLine("WROTE: {0}", json);

                JsonPayloadReader jsonReader = new JsonPayloadReader(json);
                var payloadResult = jsonReader.ReadObject<Payload>(string.Empty, Payload.CreateInstance);
                Console.WriteLine("READ OBJECT: {0}", payloadResult);

                EventSet[] events = new EventSet[]
                {
                    new EventSet { Sequence = 0, ChannelName = "test", Payloads = new Payload[] { new ClientConnectPayload(subscriptionId, clientId , ns, NamespaceLifetime.ConnectedOnly) } }
                };

                json = WriteToJson(events);
                Console.WriteLine(json);

                MemoryStream ms = new MemoryStream();
                StreamWriter sw = new StreamWriter(ms);
                sw.Write(json);
                sw.Flush();

                var eventsResult = EventSet.CreateEventSetsFromStream(ms, PayloadFormat.JSON);
                Console.WriteLine(eventsResult);

                var principal = new PrincipalObject() { Id = "Eli", Sid = "sa" };
                var es = new EventSet { Sequence = 0, ChannelName = "test", Payloads = new Payload[] { new ClientConnectPayload(subscriptionId, clientId, ns, NamespaceLifetime.ConnectedOnly, principal) } };

                json = WriteToJson(es);
                Console.Write(json);

                return;              
            };
            Browser.Document.Body.Add(jsonButton);
            
            var soButton = new Button { InnerHtml = "Subscribe Shared Objects Client" };
            soButton.Click += e =>
            {
                var guid = Guid.NewGuid();
                var txt = textbox.Value;

                string path = string.Format("http://{0}/{1}", txt, guid.ToString());

                SharedObjectsClient soc = new SharedObjectsClient(path, NamespaceLifetime.ConnectedOnly);
                PrincipalObject principal = new PrincipalObject() { Id = "ClientA", Sid = "sa" };
                soc.PrincipalObject = principal;
                
                soc.Connect();
                Console.WriteLine("Connecting to:{0}", path);
                soc.Connected += (s, ec) =>
                {
                    Console.WriteLine("CONNECTED TO SHARED OBJECTS SERVER");
                };
            };
            Browser.Document.Body.Add(soButton);

            // Conventional DOM interaction
            var subButton = new Button { InnerHtml = "Subscribe..." };
            subButton.Click += e =>
            {
                Console.WriteLine("Subscribing...");

                Uri uri = new Uri("http://elipc:4040/");
                this.client = new EventLinkClient(uri, "3bb04637-af98-40e9-ad65-64fb2668a0d2", (s, ex) =>
                {
                    Console.WriteLine(string.Format("Error state:{0} exception:{1}", s, ex));
                });
                this.client.Subscribe("99ca2aff-538e-49f2-a71c-79b7720e3f21ClientControl", EventLinkEventsReceived, this.OnSubscriptionInitialized);
                return;

                //this.Channel = new EventLinkChannel(new Uri("http://elipc:4040/"), "nameSpace", (c1, c2) =>
                //{
                //    Write("Error state changed");
                //});

                //this.Channel.SubscriptionInitialized += OnIncomingChannelsInitialized;
                //this.Channel.EventsReceived += OnIncomingChannelsDataReceived;
                //string name = Channels.GetClientName(Guid.NewGuid());
                //this.Channel.SubscribeAsync(name);

                //Uri uri = new Uri("http://elipc:4040/");
                //this.client = new EventLinkClient(uri, "f148dc15-ad26-484e-9f74-8d0655e8fc0d", (s, ex) =>
                //{
                //    Console.WriteLine(string.Format("Error state:{0} exception:{1}", s, ex));
                //});
                //this.client.Subscribe("81dddf4c-f84c-414f-9f04-99f926fc8c68ClientControl", EventLinkEventsReceived, () => this.OnSubscriptionInitialized());
            };
            Browser.Document.Body.Add(subButton);

            // Conventional DOM interaction
            var secButton = new Button { InnerHtml = "Test Security..." };
            secButton.Click += e =>
            {
                Console.WriteLine("sec");

                //var el = new EventLinkClient(new Uri("http://localhost:4040/"), "partitionA", (c) =>
                //{
                //    Write("EventLinkClient Connected");
                //});

                //var att = new SharedAttributes();
                //Write(att);

                //var client = new SharedObjectsClient("http://www.cnn.com/namespaceName");
                //Write(client);

                //client.Connect();

                Guid g = Guid.NewGuid();
                Console.WriteLine(g);

                Guid g2 = Guid.Empty;
                Console.WriteLine(g2);

                ETag e2 = new ETag(Guid.Empty);
                Console.WriteLine(e2);

                SharedObjectSecurity s = new SharedObjectSecurity("Security", false, new ETag(Guid.Empty));
                s.AddAccessRule(new SharedObjectAccessRule("Idenity", ObjectRights.ChangePermissions, System.Security.AccessControl.InheritanceFlags.ContainerInherit, System.Security.AccessControl.AccessControlType.Allow));
                Console.WriteLine(s);

                PrincipalObject p = new PrincipalObject() { Id = "Hello", Sid = "Sid" };
                Console.WriteLine(p);

                SharedEntryMap<SampleEntry> map = new SharedEntryMap<SampleEntry>();
                Console.WriteLine(map);

                var attr = new SharedAttributes();
                Console.WriteLine(attr);

                var ep = new ObjectExpirationPolicy("timespan", TimeSpan.FromDays(1), TimeSpan.FromMilliseconds(100));
                Console.WriteLine(ep);

                var v = new ProtocolVersion(1, 0);
                Console.WriteLine(v);

                //var tp = new TracePayload("Message", Guid.Empty);
                //Write(tp);


                
                //ObjectDeletedPayload p2 = new ObjectDeletedPayload(Guid.Empty, Guid.NewGuid());
                //Write(p2);

                ////WAIT FOR SAHRED PROEPRPT
                ////ClientConnectPayload c = new ClientConnectPayload("sub", Guid.Empty, "namespace");
                ////Write(c);



                //var principalObject = new PrincipalObject() { Id = "Eli", Sid = "sa" };
                ////                var principal = new ObjectPayload(Guid.NewGuid(), principalObject, Guid.NewGuid(), "NamedObject");

                //var sharedProps = new Dictionary<short, SharedProperty>();
                //Write(sharedProps);

                ////TODO THIS IS BROKEN 
                ////var spd = new SharedPropertyDictionary();
                ////Write(spd);
                
                //var puo = new PropertyUpdateOperation();
                //Write(puo);



                //JavascriptHttpStream str = new JavascriptHttpStream(null);
                //BinaryReader br = new BinaryReader(str);
                //BinaryWriter bw = new BinaryWriter(str);
                //BinaryReader br = new BinaryReader(null);
                //BinaryWriter bw = new BinaryWriter(null);

                
                
            };
            //Browser.Document.Body.Add(secButton);

            // Conventional DOM interaction
            var linqButton = new Button { InnerHtml = "Test Linq..." };
            linqButton.Click += e =>
            {
                int value = "abc".Select(a => a - 'a').Sum();
                Console.WriteLine(value);

                value = "abcdefg".Select(a => a - 'a').Sum();
                Console.WriteLine(value);
            };

            //Browser.Document.Body.Add(linqButton);
        }