示例#1
0
        private void InitCommonControlsList()
        {
            if (!Directory.Exists($"./{ControlStructureProperty.IconDirectory}"))
            {
                Directory.CreateDirectory(ControlStructureProperty.IconDirectory);

                //Download Basics
                //Unzip folder
            }
            if (!File.Exists(ControlStructureProperty.StructurePath))
            {
                //Download that for Basics
                //Load controls -> json obj -> update current structure file
            }

            var ctrlStruct = JsonConvert.DeserializeObject <JObject>(File.ReadAllText(ControlStructureProperty.StructurePath));

            if (ctrlStruct.ContainsKey(ControlStructureProperty.Basics) &&
                ctrlStruct[ControlStructureProperty.Basics].Count() >= 1)
            {
                var controls = ctrlStruct[ControlStructureProperty.Basics];
                foreach (var data in controls)
                {
                    var control = new ControlItem
                    {
                        ControlName = data[ControlStructureProperty.Name].ToString(),
                        ControlIcon =
                            new BitmapImage(new Uri(@$ "{Directory.GetCurrentDirectory()}/{ControlStructureProperty.IconDirectory}/{data[ControlStructureProperty.Icon]}")),
                        Description = data[ControlStructureProperty.Description].ToString()
                    };

                    control.MouseLeftButtonUp += new MouseButtonEventHandler(ControlItem_Selected);

                    ControlListPanel.Children.Add(control);
                }
            }
            if (ctrlStruct.ContainsKey(ControlStructureProperty.Customs) &&
                ctrlStruct[ControlStructureProperty.Customs].Count() >= 1)
            {
                //Add custom controls
            }
        }
示例#2
0
        private void ControlItem_Selected(object sender, MouseEventArgs e)
        {
            //컨트롤 선택
            var select = (sender as ControlItem);

            if (currSelected != null)
            {
                currSelected.Background = listItemColor;
            }
            if (currSelected == select)
            {
                select.Background = listItemColor;
                currSelected      = null;
                return;
            }

            //Control Brush....

            currSelected            = select;
            currSelected.Background = listItemSelectedColor;
        }