Beispiel #1
0
        /// <summary>
        /// Factory method for instanting widget objects based on the data passed in through xml
        /// </summary>
        /// <param name="reader">XML reader which is used to read serialized data object hierarchy</param>
        /// <returns>Newly created widget data instance</returns>
        public static WidgetData Create(XmlReader reader)
        {
            WidgetData widget = null;

            // LATER: This method breaks OCP since addition/removal of widget types will require modification of the
            // base class which is not desirable. For now we'll keep it this way, but if this method is revisited, we
            // should consider creating a stand-alone factory which could potentially use reflection to dynamically
            // build a list of creatable widgets.

            switch (reader.Name)
            {
            case "WidgetContainerData":
                widget = new WidgetContainerData();
                break;

            case "FolderWidgetData":
                widget = new FolderWidgetData();
                break;

            default:
                // Unknown element, skip to next one
                reader.Skip();
                break;
            }

            if (widget != null)
            {
                (( IXmlSerializable)widget).ReadXml(reader);
            }

            return(widget);
        }
Beispiel #2
0
        /// <inheritdoc/>
        protected override void OnClick(object sender, RoutedEventArgs e)
        {
            Data.FolderWidgetData data = DataContext as Data.FolderWidgetData;

            if (data != null)
            {
                Process.Start("explorer.exe", "\"" + data.Path + "\"");
            }
        }
Beispiel #3
0
        private void ProcessFileDrop(string[] filePaths, bool isMove)
        {
            IFileOperation fileOp = new FileOperationG1();

            Data.FolderWidgetData data = DataContext as Data.FolderWidgetData;

            if (data == null)
            {
                return;
            }

            fileOp.ParentWindow = Window.GetWindow(this);
            fileOp.Operation    = isMove ? FILEOP_CODES.FO_MOVE :
                                  FILEOP_CODES.FO_COPY;
            fileOp.From = filePaths;
            fileOp.To   = new string[1] {
                data.Path
            };
            fileOp.Flags = FILEOP_FLAGS.FOF_ALLOWUNDO;

            fileOp.Execute();
        }
Beispiel #4
0
        /// <summary>
        /// Factory method for instanting widget objects based on the data passed in through xml
        /// </summary>
        /// <param name="reader">XML reader which is used to read serialized data object hierarchy</param>
        /// <returns>Newly created widget data instance</returns>
        public static WidgetData Create( XmlReader reader )
        {
            WidgetData      widget = null;

            // LATER: This method breaks OCP since addition/removal of widget types will require modification of the
            // base class which is not desirable. For now we'll keep it this way, but if this method is revisited, we
            // should consider creating a stand-alone factory which could potentially use reflection to dynamically
            // build a list of creatable widgets.

            switch( reader.Name )
            {
                case "WidgetContainerData":
                    widget = new WidgetContainerData();
                    break;
                case "FolderWidgetData":
                    widget = new FolderWidgetData();
                    break;
                default:
                    // Unknown element, skip to next one
                    reader.Skip();
                    break;
            }

            if( widget != null )
            {
                ( ( IXmlSerializable)widget ).ReadXml( reader );
            }

            return widget;
        }