Esempio n. 1
0
        public void AddToolbarItem(ImageSource imageSource, ITool tool, ICommand command)
        {
            if (tool != null && ToolCollection.Tools.Any(n => n.Name == tool.Name))
            {
                throw new VerificationException("Tool already exists");
            }

            var newSketchToolbarItem = new SketchToolbarItem(imageSource, tool, command ?? ActivateToolCommand)
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                WidthRequest    = ToolbarHeight,
                IsSelected      = toolbarStack.Children.Count == 0            // Select the first added tool
            };

            toolbarStack.Children.Add(newSketchToolbarItem);

            if (tool != null)
            {
                ToolCollection.Tools.Add(tool);
                if (newSketchToolbarItem.IsSelected)
                {
                    ToolCollection.ActivateTool(tool);
                }
            }
        }
Esempio n. 2
0
        private void bindToolBar_Click(object sender, EventArgs e)
        {
            var collection  = ToolCollection.GetToolCollection();
            var mainControl = (ToolStrip)GetMainControlByName("toolBar1");

            foreach (var item in collection)
            {
                var isMatch = false;
                foreach (object component in mainControl.Items)
                {
                    if (isMatch)
                    {
                        break;
                    }

                    if (((INamedBindable)component).Name == item.Name)
                    {
                        ((IBindableComponent)component).DataBindings.Add("Text", item, "Text");
                        ((IBindableComponent)component).DataBindings.Add("ToolTipText", item, "ToolTipText");
                        ((IBindableComponent)component).DataBindings.Add("Enabled", item, "Enabled");
                        ((IBindableComponent)component).DataBindings.Add("Visible", item, "Visible");
                        isMatch = true;
                    }
                }
            }
        }
Esempio n. 3
0
 private void UpdateToolVersions()
 {
     ToolCollection.Clear();
     foreach (ToolVersions ver in _tempToolCollection)
     {
         ToolCollection.Add(ver);
     }
 }
Esempio n. 4
0
        void UpdaterProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            if (e.ProgressPercentage == -20)
            {
                ToolCollection.Remove((ToolVersions)e.UserState);
            }
            else
            {
                StatusBar.IsIndeterminate = e.ProgressPercentage < 0;
                StatusBar.Value           = e.ProgressPercentage;

                StatusText.Content = e.UserState;
            }
        }
Esempio n. 5
0
        public SketchView()
        {
            InitializeComponent();
            ToolCollection      = new ToolCollection();
            ActivateToolCommand = new Command <ITool>(ActivateTool);
            UndoCommand         = new Command(() => { ToolCollection.Undo(); });
            UndoAllCommand      = new Command(() => { ToolCollection.UndoAll(); });


            SetToolbarHeight(toolbarStack, ToolbarHeight);

            sketchArea.Delegates.Add(ToolCollection);
            sketchArea.ToolCollection = ToolCollection;
        }
Esempio n. 6
0
        private void ActivateTool(ITool tool)
        {
            if (SelectedTool?.Name == tool?.Name)
            {
                OpenToolSettings(SelectedTool);
                return;
            }

            ToolCollection.ActivateTool(tool);

            // Unselect all items
            foreach (var child in toolbarStack.Children.Where(n => n is SketchToolbarItem))
            {
                var toolBarItem = (SketchToolbarItem)child;
                toolBarItem.IsSelected = toolBarItem?.Tool == tool;
            }
        }
Esempio n. 7
0
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List< ToolInfo> pList, ToolCollection pCollection)
 {
     foreach (Tool tool in pCollection)
     {
         ToolInfo toolInfo = new ToolInfo();
         LoadFromDAL(toolInfo, tool );
         pList.Add(toolInfo);
     }
 }
Esempio n. 8
0
        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List<ToolInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount)
        {
            if(pPageIndex<=1)
            pPageIndex=1;
            List< ToolInfo> list = new List< ToolInfo>();

            Query q = Tool .CreateQuery();
            q.PageIndex = pPageIndex;
            q.PageSize = pPageSize;
            q.ORDER_BY(pSortExpression,pOrderBy.ToString());
            ToolCollection  collection=new  ToolCollection();
             	collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (Tool  tool  in collection)
            {
                ToolInfo toolInfo = new ToolInfo();
                LoadFromDAL(toolInfo,   tool);
                list.Add(toolInfo);
            }
            pRecordCount=q.GetRecordCount();

            return list;
        }
Esempio n. 9
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 /// <returns></returns>
 public static List<ToolInfo> GetList()
 {
     string cacheKey = GetCacheKey();
     //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
     if (CachedEntityCommander.IsTypeRegistered(typeof(ToolInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
     {
         return CachedEntityCommander.GetCache(cacheKey) as List< ToolInfo>;
     }
     else
     {
         List< ToolInfo>  list =new List< ToolInfo>();
         ToolCollection  collection=new  ToolCollection();
         Query qry = new Query(Tool.Schema);
         collection.LoadAndCloseReader(qry.ExecuteReader());
         foreach(Tool tool in collection)
         {
             ToolInfo toolInfo= new ToolInfo();
             LoadFromDAL(toolInfo,tool);
             list.Add(toolInfo);
         }
       	//生成缓存
         if (CachedEntityCommander.IsTypeRegistered(typeof(ToolInfo)))
         {
             CachedEntityCommander.SetCache(cacheKey, list);
         }
         return list;
     }
 }