public override void Apply(IScreenItem Source)
        {
            base.Apply(Source);
            var source = Source as IScreenSection;

            Apply_Actual(source);
        }
Example #2
0
        public override void Apply(IScreenItem sourceItem)
        {
            var source = sourceItem as IScreenField;

            base.Apply(source);
            this.Usage = source.Usage;
        }
    public static ScreenItemInstance FindItem(
      this IScreenItem item, IScreenLoc Start, IScreenLoc FindZeroLoc, 
      ScreenContent Content)
    {
      ScreenItemInstance findItem = null;

      if (item.ItemType == ShowItemType.Section)
      {
        var sectionItem = item as IScreenSection;
        findItem = sectionItem.FindItem(Start, FindZeroLoc, Content);
      }

      else
      {
        // adjust screen loc of the item by start pos of the section it is contained in.
        var adjRow = Start.RowNum - 1;
        var adjCol = Start.ColNum - 1;
        var loc = new OneScreenLoc(
          item.ScreenLoc.RowNum + adjRow, item.ScreenLoc.ColNum + adjCol);
        var zeroLoc = loc.ToZeroRowCol();

        var itemAtomic = item as IScreenAtomic;
        var range = new ScreenLocRange(zeroLoc, itemAtomic.Length, Content.ScreenDim);
        if (range.Contains(FindZeroLoc) == true)
          findItem = new ScreenItemInstance(item, range.From);
      }

      return findItem;
    }
Example #4
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modItems)
        {
            IScreenItem item = items.First() as IScreenItem;

            item.Viewport.RestoreLayout();
            return(null);
        }
 public static string GetValue( this IScreenItem Item)
 {
   if (Item is IScreenLiteral)
     return (Item as IScreenLiteral).Value;
   else
     return "";
 }
        public static ScreenItemModel Factory(ShowItemType ItemType, IScreenItem source)
        {
            var item  = ScreenItem.Factory(ItemType, source);
            var model = ScreenItemModel.Factory(item);

            return(model);
        }
Example #7
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modItems)
        {
            IScreenItem screen = modItems.First() as IScreenItem;

            IEnumerable <Window> windows = null;

            if (items.First() is IApplicationItem)
            {
                windows = items.Cast <IApplicationItem> ().SelectMany(app => WindowUtils.WindowListForCmd(app.Exec));
            }
            else if (items.First() is IWindowItem)
            {
                windows = items.Cast <IWindowItem> ().SelectMany(wi => wi.Windows);
            }

            if (windows != null)
            {
                foreach (Wnck.Window window in windows)
                {
                    screen.Viewport.MoveWindowInto(window);
                }
            }

            return(null);
        }
Example #8
0
        public void InsertItemBefore(IScreenItem item, IScreenItem nextItem)
        {
            //create a temp list to hold everything
            var tempItems = new List <IScreenItem>();

            //add all the items to the list
            foreach (var currentItem in Items)
            {
                //check if this is the item to add after
                if (currentItem == nextItem)
                {
                    tempItems.Add(item);
                }

                tempItems.Add(currentItem);
            }

            //create a new layout list
            Items = new List <IScreenItem>();

            //add all the temp items to the layout list
            foreach (var tempItem in tempItems)
            {
                AddItem(tempItem);
            }
        }
Example #9
0
        /// <summary>
        /// construct a new ScreenItem with the specific itemType. Then apply properties
        /// from the source item.
        /// </summary>
        /// <param name="itemType"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        public static IScreenItem Factory(ShowItemType itemType, IScreenItem source)
        {
            var item = Factory(itemType);

            item.ApplyMatch(source);
            return(item);

            if (item is ScreenAtomic)
            {
                var atomic = item as ScreenAtomic;
                if (source is IScreenAtomic)
                {
                    atomic.Apply(source as IScreenAtomic);
                }
                else
                {
                    (item as ScreenItem).ApplyMatch(source as IScreenItem);
                }
            }

            else if (item is ScreenSection)
            {
                var section = item as ScreenSection;
                if (source is IScreenSection)
                {
                    section.Apply(source);
                }
                else
                {
                    (section as ScreenItem).ApplyMatch(source);
                }
            }

            return(item);
        }
Example #10
0
        public static IScreenItem Factory(ShowItemType itemType)
        {
            IScreenItem item = null;

            if ((itemType == ShowItemType.Field) ||
                (itemType == ShowItemType.StaticLit) ||
                (itemType == ShowItemType.VarLit))
            {
                item = new ScreenField();
            }
            else if ((itemType == ShowItemType.Literal) || (itemType == ShowItemType.Static))
            {
                item = new ScreenLiteral();
            }
            else if (itemType == ShowItemType.Section)
            {
                item = new ScreenSection();
            }
            else
            {
                throw new Exception("unsupported itemType");
            }

            return(item);
        }
Example #11
0
        /// <summary>
        /// Set the position of a widget to be relative to this layout
        /// </summary>
        /// <param name="item"></param>
        private void SetItemPosition(IScreenItem item, Rectangle rect)
        {
            //point to set the location of the item
            Point pos = Point.Zero;

            switch (item.Horizontal)
            {
            case HorizontalAlignment.Center: { pos.X = Rect.Center.X; } break;

            case HorizontalAlignment.Left: { pos.X = Rect.Left; } break;

            case HorizontalAlignment.Right: { pos.X = Rect.Right; } break;
            }

            switch (item.Vertical)
            {
            case VerticalAlignment.Center: { pos.Y = Rect.Center.Y; } break;

            case VerticalAlignment.Top: { pos.Y = Rect.Top; } break;

            case VerticalAlignment.Bottom: { pos.Y = Rect.Bottom; } break;
            }

            //set the position of the new item
            item.Position = pos;
        }
Example #12
0
        public bool RemoveItem(IScreenItem item)
        {
            var result = Layout.RemoveItem(item);

            CalculateRect();
            return(result);
        }
Example #13
0
    public static IScreenItem ToScreenItem(this XElement Elem, XNamespace Namespace)
    {
      IScreenItem item = null;
      if (Elem != null)
      {
        // first get itemType. Could be field, literal or section.
        var itemType = Elem.Element(Namespace + "ItemType").StringOrDefault("").TryParseShowItemType().Value;
        var itemName = Elem.Element(Namespace + "ItemName").StringOrDefault("");
        var screenLoc = Elem.Element(Namespace + "ScreenLoc").ToScreenLoc(Namespace) as OneScreenLoc;
        var hoverCode = Elem.Element(Namespace + "HoverCode").ToIEnumerableString("Item").ToArray();
        var hoverXaml = Elem.Element(Namespace + "HoverXaml").ToIEnumerableString("Item").ToArray();

        item = ScreenItem.Factory(itemType);

        item.ItemType = itemType;
        item.ItemName = itemName;
        item.MatchNum = Elem.Element(Namespace + "MatchNum").IntOrDefault(0).Value;
        item.ItemGuid = Elem.Element(Namespace + "ItemGuid").StringOrDefault(null);
        item.IsOptional = Elem.Element(Namespace + "IsOptional").BooleanOrDefault(false).Value;
        item.ScreenLoc = screenLoc;
        item.HoverCode = hoverCode;
        item.HoverXaml = hoverXaml;

        if (item is IScreenAtomic)
        {
          var atom = item as ScreenAtomic;
          atom.Length = Elem.Element(Namespace + "Length").IntOrDefault(0).Value;
          atom.DsplyAttr = Elem.Element(Namespace + "DsplyAttr").ToDsplyAttr(Namespace);
        }

        if (item is ScreenLiteral)
        {
          var lit = item as ScreenLiteral;
          lit.ListValues = Elem.Element(Namespace + "ListValues").ListStringOrDefault(Namespace, "Item", null);
        }

        if (item is IScreenField)
        {
          var fld = item as IScreenField;
          fld.Usage = Elem.Element(Namespace + "Usage").StringOrDefault("").TryParseShowUsage().Value;
        }

        if (item is IScreenSection)
        {
          var sect = item as IScreenSection;

          var itemList = Elem.Element(Namespace + "ItemList").ToScreenItemList(Namespace);
          sect.Items = new List<IScreenItem>();
          var sectionHeader = item as ISectionHeader;
          sectionHeader.LoadItems(itemList);

          sect.RepeatCount = Elem.Element(Namespace + "RepeatCount").IntOrDefault(0).Value;
          sect.IsExpanded = Elem.Element(Namespace + "IsExpanded").BooleanOrDefault(false).Value;
          sect.AssocSectionName = Elem.Element(Namespace + "AssocSectionName").StringOrDefault("");
          sect.PurposeCode = Elem.Element(Namespace + "PurposeCode").StringOrDefault("").TryParseScreenPurposeCode();
        }
      }
      return item;
    }
Example #14
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modItems)
        {
            IScreenItem item = items.First() as IScreenItem;

            item.Viewport.ShowDesktop();

            return(null);
        }
Example #15
0
        public override void Apply(IScreenItem sourceItem)
        {
            var source = sourceItem as IScreenLiteral;

            base.Apply(source);
//      this.Value = source.Value;
            this.ListValues = source.ListValues.ToList();
        }
Example #16
0
        /// <summary>
        /// Set the position of the item as store it
        /// </summary>
        /// <param name="item"></param>
        public override void AddItem(IScreenItem item)
        {
            SetItemPosition(item, CalculateRect());

            //store the new item
            Items.Add(item);
            Sort();
        }
        public override void Apply(IScreenItem Source)
        {
            var source = Source as IScreenAtomic;

            base.Apply(source);
            this.Length    = source.Length;
            this.DsplyAttr = source.DsplyAttr;
        }
Example #18
0
        /// <summary>
        /// Set the position of a widget to be relative to this layout
        /// </summary>
        /// <param name="item"></param>
        protected virtual void UpdateItemPosition(IScreenItem item, Rectangle rect)
        {
            //Get the delta position
            var delta = PreviousRect.Location - rect.Location;

            //add the delt to the current position
            item.Position -= delta;
        }
Example #19
0
    public static Tuple<DataItem, DataItemReport> CaptureReport(
      this IScreenItem item, IScreenLoc Start, ScreenContent Content)
    {
      string captureText = null;
      DataItem dataItem = null;
      DataItemReport itemReport = null;
      ContentItemBase contentItem = null;

      // get the content item at the rowcol location.
      bool rc = true;
      IScreenAtomic atomicItem = null;

      // adjust screen loc of the item by start pos of the section it is contained in.
      var adjRow = Start.RowNum - 1;
      var adjCol = Start.ColNum - 1;
      var loc = new OneScreenLoc(
        item.ScreenLoc.RowNum + adjRow, item.ScreenLoc.ColNum + adjCol);
      var zeroLoc = loc.ToZeroRowCol();

      if (item.ItemType != ShowItemType.Section)
      {
        rc = Content.FieldDict.TryGetValue(zeroLoc, out contentItem);
        atomicItem = item as IScreenAtomic;
      }

      if (rc == false)
      {
      }

      else if (item.ItemType == ShowItemType.Section)
      {
        var sectionItem = item as IScreenSection;
        itemReport = sectionItem.CaptureReport(Content);
      }

      else if (item.ItemType == ShowItemType.Field)
      {
        if ((contentItem is ContentField) == true)
        {
          var contentField = contentItem as ContentField;
          dataItem = new DataItem(item.ItemName, contentField.GetShowText(Content));
          captureText = item.ItemName + "=" + contentField.GetShowText(Content);
        }
      }

      // match fixed literal
      else if (item.ItemType == ShowItemType.Literal)
      {
        if ((contentItem is ContentText) == true)
        {
          var contentText = contentItem as ContentText;
          var itemLit = item as IScreenLiteral;
          var ctValue = contentText.GetShowText(Content).TrimEndWhitespace();
        }
      }

      return new Tuple<DataItem, DataItemReport>(dataItem, itemReport);
    }
 public override void ApplyMatch(IScreenItem sourceItem)
 {
     base.ApplyMatch(sourceItem);
     if (sourceItem is IScreenField)
     {
         var source = sourceItem as IScreenField;
         this.Usage = source.Usage;
     }
 }
Example #21
0
 void Apply_Actual(IScreenItem source)
 {
     this.ItemName   = source.ItemName;
     this.ItemGuid   = source.ItemGuid;
     this.MatchNum   = source.MatchNum;
     this.ScreenLoc  = source.ScreenLoc;
     this.HoverCode  = source.HoverCode;
     this.IsOptional = source.IsOptional;
 }
 public override void ApplyMatch(IScreenItem sourceItem)
 {
     base.ApplyMatch(sourceItem);
     if (sourceItem is IScreenSection)
     {
         var source = sourceItem as IScreenSection;
         Apply_Actual(source);
     }
 }
Example #23
0
 /// <summary>
 /// apply source to target where the types match.
 /// </summary>
 /// <param name="sourceItem"></param>
 public override void ApplyMatch(IScreenItem sourceItem)
 {
     base.ApplyMatch(sourceItem);
     if (sourceItem is IScreenLiteral)
     {
         var source = sourceItem as IScreenLiteral;
         this.ListValues = source.ListValues.ToObservableCollection();
     }
 }
Example #24
0
        public override void ApplyMatch(IScreenItem sourceItem)
        {
            base.ApplyMatch(sourceItem);
            if (sourceItem is IScreenLiteral)
            {
                var source = sourceItem as IScreenLiteral;
//        this.Value = source.Value;
                this.ListValues = source.ListValues.ToList();
            }
        }
        public override void Apply(IScreenItem Item)
        {
            base.Apply(Item);

            if (Item is IScreenField)
            {
                var item = Item as IScreenField;
                this.Usage = item.Usage;
            }
        }
Example #26
0
        public override void AddItem(IScreenItem item)
        {
            PrepareAdd(item);

            //add to the stack control
            Stack.AddItem(item);

            UpdateMinMaxScroll();
            UpdateScrollBars();
        }
Example #27
0
        public void InsertItem(IScreenItem item, IScreenItem prevItem)
        {
            PrepareAdd(item);

            //add to the stack control
            Stack.InsertItem(item, prevItem);

            UpdateMinMaxScroll();
            UpdateScrollBars();
        }
Example #28
0
        public override void AddItem(IScreenItem item)
        {
            var widget = item as IWidget;

            if (null != widget)
            {
                widget.TransitionObject = new WipeTransitionObject(TransitionWipeType.None);
            }
            base.AddItem(item);
        }
Example #29
0
        public void InsertItemBefore(IScreenItem item, IScreenItem nextItem)
        {
            PrepareAdd(item);

            //add to the stack control
            Stack.InsertItemBefore(item, nextItem);

            UpdateMinMaxScroll();
            UpdateScrollBars();
        }
 public override void ApplyMatch(IScreenItem Source)
 {
     base.ApplyMatch(Source);
     if (Source is IScreenAtomic)
     {
         var source = Source as IScreenAtomic;
         this.Length    = source.Length;
         this.DsplyAttr = source.DsplyAttr;
     }
 }