Exemplo n.º 1
0
        public msg Execute(msg m)
        {
            if (m == null || m.Input == null)
            {
                return(m);
            }
            bool hasUpdate = false;

            switch (m.KEY)
            {
            case _API.SETTING_APP_KEY_UPDATE_FOLDER:
                #region
                string fol = (string)m.Input;
                if (!string.IsNullOrEmpty(fol))
                {
                    fol = fol.ToLower().Trim();
                    lock (_lock)
                    {
                        if (_setting.list_folder.IndexOf(fol) == -1)
                        {
                            _setting.list_folder.Add(fol);
                            hasUpdate = true;
                            app.postMessageToService(new msg()
                            {
                                API = _API.FOLDER_ANYLCTIC, Input = fol
                            });
                        }
                    }
                }
                #endregion
                break;

            case _API.SETTING_APP_KEY_UPDATE_NODE_OPENING:
                oNode node = (oNode)m.Input;
                lock (_lock)
                    _setting.node_opening = node.id;
                hasUpdate = true;
                break;

            case _API.SETTING_APP_KEY_UPDATE_SIZE:
                oAppSize app_size = (oAppSize)m.Input;
                lock (_lock)
                {
                    _setting.app_size = app_size;
                    hasUpdate         = true;
                }
                break;
            }

            //if (hasUpdate)
            //{
            //    using (var file = File.Create(file_name))
            //    {
            //        Serializer.Serialize<oSetting>(file, _setting);
            //    }
            //}
            m.Output.Ok   = hasUpdate;
            m.Output.Data = hasUpdate;
            return(m);
        }
Exemplo n.º 2
0
 public static void Add(oNode node)
 {
     lock (_lock)
         dicItems.Add(node.id, node);
 }
Exemplo n.º 3
0
        private oNode node_Parse(string path_file)
        {
            if (!File.Exists(path_file))
            {
                return(null);
            }

            oNode node = new oNode();

            node.path = path_file;
            node.name = Path.GetFileName(path_file);

            switch (Path.GetExtension(path_file).ToLower())
            {
            case ".txt":
                node.type    = oNodeType.TEXT;
                node.content = File.ReadAllText(path_file);
                node.title   = node.content.Split(new char[] { '\r', '\n' })[0];
                break;

            case ".pdf":
                node.type  = oNodeType.PDF;
                node.title = node.name.Substring(0, node.name.Length - 4).Trim();
                break;

            case ".html":
                node.type  = oNodeType.HTML;
                node.title = node.name.Substring(0, node.name.Length - 5).Trim();
                break;

            case ".htm":
                node.type  = oNodeType.HTM;
                node.title = node.name.Substring(0, node.name.Length - 4).Trim();
                break;

            case ".doc":
                node.type  = oNodeType.DOC;
                node.title = node.name.Substring(0, node.name.Length - 4).Trim();
                break;

            case ".docx":
                node.type  = oNodeType.DOCX;
                node.title = node.name.Substring(0, node.name.Length - 5).Trim();
                break;

            case ".xls":
                node.type  = oNodeType.XLS;
                node.title = node.name.Substring(0, node.name.Length - 4).Trim();
                break;

            case ".xlsx":
                node.type  = oNodeType.XLSX;
                node.title = node.name.Substring(0, node.name.Length - 5).Trim();
                break;

            case ".ppt":
                node.type  = oNodeType.PPT;
                node.title = node.name.Substring(0, node.name.Length - 4).Trim();
                break;

            case ".pptx":
                node.type  = oNodeType.PPTX;
                node.title = node.name.Substring(0, node.name.Length - 5).Trim();
                break;

            default:
                node = null;
                break;
            }
            return(node);
        }
Exemplo n.º 4
0
        public uiItemLabel(oNode node, IconType iconType = IconType._none)
        {
            _node = node;
            string text = node.title;

            _detail = new FlowLayoutPanel()
            {
                Visible    = false,
                AutoScroll = true,
                //Dock = DockStyle.Fill,
                BackColor     = Color.White,
                FlowDirection = FlowDirection.RightToLeft,
                WrapContents  = true,
                Padding       = new Padding(7, 0, 0, 0),
                RightToLeft   = RightToLeft.Yes,
                BorderStyle   = BorderStyle.None,
                Margin        = new Padding(0),
            };
            _exit = new IconButton()
            {
                IconType = IconType.close_circled, Visible = false
            };
            _text = new Label()
            {
                Text = text, AutoSize = true, TextAlign = ContentAlignment.TopLeft
            };
            _state = new Label()
            {
                Dock = DockStyle.Left, AutoSize = false, Width = 1
            };

            using (Graphics g = CreateGraphics())
            {
                SizeF size = g.MeasureString(text, _text.Font);
                wi_text = (int)Math.Ceiling(size.Width);
            }

            if (iconType != IconType._none)
            {
                _icon = new IconButton(19)
                {
                    IconType = iconType, Location = new Point(3, 5), Width = 19
                };
                this.Controls.Add(_icon);

                wi_header      = wi_text + _icon.Width + _state.Width;
                _text.Location = new Point(_icon.Width + _state.Width, 5);
            }
            else
            {
                wi_header      = wi_text + _state.Width;
                _text.Location = new Point(_state.Width, 5);
            }

            this.Width = wi_header;

            this.Controls.AddRange(new Control[] { _text, _state, _exit, _detail });
            _text.Click += _text_Click;
            _exit.Click += _text_Click;
            this.Click  += _text_Click;

            this.HandleCreated += (se, ev) =>
            {
                if (wi_header > this.Parent.Width)
                {
                    wi_header  = this.Parent.Width;
                    this.Width = wi_header;
                }
            };
        }