Changeset 1621


Ignore:
Timestamp:
Jun 11, 2010, 5:53:30 AM (11 years ago)
Author:
matkovic
Message:
  • Plugin resize now working
  • each PluginType now distinguish in color
Location:
trunk/CrypPlugins/WorkspaceManager
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/WorkspaceManager/Model/ColorHelper.cs

    r1595 r1621  
    55using System.Numerics;
    66using System.Windows.Media;
     7using Cryptool.PluginBase;
     8using System.Reflection;
     9using Cryptool.PluginBase.Cryptography;
     10using Cryptool.PluginBase.Analysis;
     11using Cryptool.PluginBase.Generator;
    712
    813namespace WorkspaceManager.Model
    914{
    1015    public class ColorHelper
    11     {       
     16    {
    1217        /// <summary>
    1318        /// Returns a Color for a given Type
     
    1924        /// <param name="obj"></param>
    2025        /// <returns></returns>
    21         public static Color getColor(Type type)
     26        public static Color GetDataColor(Type type)
    2227        {
    2328            if (type.FullName == "System.String")
     
    5560            }
    5661        }
     62
     63        /// <summary>
     64        /// Return color from a giving PluginType
     65        /// </summary>
     66        /// <param name="type"></param>
     67        /// <returns></returns>
     68        public static Color GetPluginTypeColor(Type type)
     69        {
     70            if (type.GetInterface(typeof(IEncryption).Name) != null)
     71            {
     72                EncryptionTypeAttribute eta = type.GetEncryptionTypeAttribute();
     73                switch (eta.EncryptionType)
     74                {
     75                    case EncryptionType.Asymmetric:
     76                        return Colors.MediumSeaGreen;
     77
     78                    case EncryptionType.Classic:
     79                        return Colors.LightBlue;
     80
     81                    case EncryptionType.SymmetricBlock:
     82                        return Colors.LightYellow;
     83
     84                    case EncryptionType.SymmetricStream:
     85                        return Colors.LightSteelBlue;
     86
     87                    case EncryptionType.Hybrid:
     88                        return Colors.Khaki;
     89                }
     90            }
     91
     92            if (type.GetInterface(typeof(IGenerator).Name) != null)
     93            {
     94                return Colors.LemonChiffon;
     95            }
     96
     97            if (type.GetInterface(typeof(IHash).Name) != null)
     98            {
     99                return Colors.Orange;
     100            }
     101
     102            if (type.GetInterface(typeof(IStatistic).Name) != null)
     103            {
     104                return Colors.Violet;
     105            }
     106
     107            if (type.GetInterface(typeof(IAnalysisMisc).Name) != null)
     108            {
     109                return Colors.Turquoise;
     110            }
     111
     112            return Colors.Black;
     113        }
    57114    }
    58115}
  • trunk/CrypPlugins/WorkspaceManager/View/Container/ConnectorView.xaml.cs

    r1600 r1621  
    6565            this.Model = cModel;
    6666            InitializeComponent();
    67             Color color = ColorHelper.getColor(cModel.ConnectorType);
     67            Color color = ColorHelper.GetDataColor(cModel.ConnectorType);
    6868            this.Ellipse.Fill = new SolidColorBrush(Color.FromArgb(color.A, color.R, color.G, color.B));
    6969            this.Ellipse.ToolTip = cModel.ToolTip;
  • trunk/CrypPlugins/WorkspaceManager/View/Container/PluginContainerView.xaml

    r1600 r1621  
    55             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    66             xmlns:e="clr-namespace:WorkspaceManager.View.Container"
    7              MinHeight="120" MinWidth="160"
     7             MinHeight="100" MinWidth="130"
    88             mc:Ignorable="d">
    99    <UserControl.Background>
     
    4141       
    4242        <Border Name="Window" Background="{StaticResource ResourceKey=GlassBrush}" CornerRadius="7" BorderBrush="#82bbef" BorderThickness="1.3">
    43             <Grid Name="PresentationBase" Width="Auto" Height="Auto">
    44                 <Grid.RowDefinitions>
    45                     <RowDefinition Height="20"></RowDefinition>
    46                     <RowDefinition Height="*"></RowDefinition>
    47                 </Grid.RowDefinitions>
    48                 <Rectangle Margin="10,5,10,5" Height="10" Opacity="0.5" Fill="#82bbef"/>
     43            <Grid>
     44                <Thumb Name="BottomDelta" Opacity="0" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Cursor="SizeNS" DragDelta="Thumb_DragDelta"></Thumb>
     45                <Thumb Name="RightDelta" Opacity="0" HorizontalAlignment="Right" VerticalAlignment="Stretch" Cursor="SizeWE" DragDelta="Thumb_DragDelta" ></Thumb>
     46                <Thumb Name="BottomRightDelta" Opacity="0" HorizontalAlignment="Right" VerticalAlignment="Bottom" Cursor="SizeNWSE" Height="15" Width="15" DragDelta="Thumb_DragDelta"></Thumb>
     47                <Grid Name="PresentationBase" Width="Auto" Height="Auto" Margin="3">
     48                    <Grid.RowDefinitions>
     49                        <RowDefinition Height="20"></RowDefinition>
     50                        <RowDefinition Height="*"></RowDefinition>
     51                    </Grid.RowDefinitions>
     52                    <Rectangle Name="PluginNamePlate" Margin="2.5,1.25,2.5,1.25" Height="10" Opacity="0.5" Fill="#82bbef"/>
    4953               
    50                 <Label Name="PluginName" FontSize="11" Margin="5,-2,0,0" FontFamily="Georgia" Foreground="WhiteSmoke" Content="test" HorizontalAlignment="left"></Label>
     54                    <Label Name="PluginName" FontSize="11" Margin="3,-2,0,0" FontFamily="Georgia" Foreground="WhiteSmoke" Content="test" HorizontalAlignment="left"></Label>
    5155
    52                 <Grid Grid.Row="1" Name="PresentationPanel" Width="Auto" Height="Auto" MaxHeight="70" MaxWidth="70" Margin="10,0,10,10" Background="Transparent">
    53                     <Grid.Effect>
    54                         <DropShadowEffect BlurRadius="2" Color="Black" ShadowDepth="0.1" Direction="90" Opacity="0.4"></DropShadowEffect>
    55                     </Grid.Effect>
     56                    <Grid Grid.Row="1" Name="PresentationPanel" Width="Auto" Height="Auto" MaxHeight="70" MaxWidth="70" Margin="5,0,5,5" Background="Transparent">
     57                        <Grid.Effect>
     58                            <DropShadowEffect BlurRadius="2" Color="Black" ShadowDepth="0.1" Direction="90" Opacity="0.4"></DropShadowEffect>
     59                        </Grid.Effect>
     60                    </Grid>
    5661                </Grid>
    5762            </Grid>
  • trunk/CrypPlugins/WorkspaceManager/View/Container/PluginContainerView.xaml.cs

    r1609 r1621  
    1414using WorkspaceManager.View.Interface;
    1515using WorkspaceManager.Model;
     16using System.Windows.Controls.Primitives;
    1617
    1718namespace WorkspaceManager.View.Container
     
    2829        private Image img;
    2930
     31        public VisualBrush VisualBrush { get; set; }
     32
    3033        private List<ConnectorView> connectorViewList;
    3134        public List<ConnectorView> ConnectorViewList
     
    5255        public PluginContainerView(PluginModel model)
    5356        {
    54             this.ConnectorViewList = new List<ConnectorView>();
    5557            this.Loaded += new RoutedEventHandler(PluginContainerView_Loaded);
    5658            this.MouseEnter += new MouseEventHandler(PluginContainerView_MouseEnter);
    5759            this.MouseLeave += new MouseEventHandler(PluginContainerView_MouseLeave);
     60            this.ConnectorViewList = new List<ConnectorView>();
     61            this.RenderTransform = new TranslateTransform();
    5862            this.model = model;
    5963            this.model.UpdateableView = this;
    60             this.RenderTransform = new TranslateTransform();
    6164            InitializeComponent();
    6265
     66            Window.BorderBrush = new SolidColorBrush(ColorHelper.GetPluginTypeColor(model.PluginType));
     67            PluginNamePlate.Fill = Window.BorderBrush;
     68
    6369            if (model.PluginPresentation != null)
    6470            {
     
    7985        void PluginContainerView_Loaded(object sender, RoutedEventArgs e)
    8086        {
    81             //TODO: Better-> Bindings
    8287            if (model.PluginPresentation == null)
    8388            {
     
    217222
    218223        #endregion
     224
     225        private void Thumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
     226        {
     227            Thumb t = sender as Thumb;
     228
     229            if (t.Cursor == Cursors.SizeWE)
     230            {
     231                if((this.ActualWidth + e.HorizontalChange) > 0)
     232                    this.Width = this.ActualWidth + e.HorizontalChange;
     233            }
     234
     235            if (t.Cursor == Cursors.SizeNS)
     236            {
     237                if((this.ActualHeight + e.VerticalChange) > 0)
     238                    this.Height = this.ActualHeight + e.VerticalChange;
     239            }
     240
     241            if (t.Cursor == Cursors.SizeNWSE)
     242            {
     243                if ((this.ActualHeight + e.VerticalChange) > 0)
     244                    this.Height = this.ActualHeight + e.VerticalChange;
     245
     246                if ((this.ActualWidth + e.HorizontalChange) > 0)
     247                    this.Width = this.ActualWidth + e.HorizontalChange;
     248            }
     249        }
     250
    219251    }
    220252
  • trunk/CrypPlugins/WorkspaceManager/View/Container/WorkSpaceEditorView.xaml.cs

    r1620 r1621  
    3636        private PluginContainerView selectedPluginContainer;
    3737        private CryptoLineView dummyLine = new CryptoLineView();
    38         private Point p;
     38        private Point point;
    3939
    4040        public EditorState State;
     
    7575        void WorkSpaceEditorView_Loaded(object sender, RoutedEventArgs e)
    7676        {
    77 
    7877        }
    7978
    8079        public void AddPluginContainerView(Point position, PluginModel model)
    8180        {
    82             PluginContainerView shape = new PluginContainerView(model);
    83             shape.Delete += new EventHandler<PluginContainerViewDeleteViewEventArgs>(PluginDelete);
    84             shape.ShowSettings += new EventHandler<PluginContainerViewSettingsViewEventArgs>(shape_ShowSettings);
    85             shape.OnConnectorMouseLeftButtonDown += new EventHandler<ConnectorViewEventArgs>(shape_OnConnectorMouseLeftButtonDown);
    86             shape.MouseLeftButtonDown += new MouseButtonEventHandler(shape_MouseLeftButtonDown);
    87             shape.MouseLeftButtonUp += new MouseButtonEventHandler(shape_MouseLeftButtonUp);
    88             shape.SetPosition(position);
    89             this.root.Children.Add(shape);
    90             Canvas.SetZIndex(shape, 100);
     81            PluginContainerView newPluginContainerView = new PluginContainerView(model);
     82            newPluginContainerView.Delete += new EventHandler<PluginContainerViewDeleteViewEventArgs>(PluginDelete);
     83            newPluginContainerView.ShowSettings += new EventHandler<PluginContainerViewSettingsViewEventArgs>(shape_ShowSettings);
     84            newPluginContainerView.OnConnectorMouseLeftButtonDown += new EventHandler<ConnectorViewEventArgs>(shape_OnConnectorMouseLeftButtonDown);
     85            newPluginContainerView.MouseLeftButtonDown += new MouseButtonEventHandler(shape_MouseLeftButtonDown);
     86            newPluginContainerView.MouseLeftButtonUp += new MouseButtonEventHandler(shape_MouseLeftButtonUp);
     87            newPluginContainerView.SetPosition(position);
     88            this.root.Children.Add(newPluginContainerView);
     89            Canvas.SetZIndex(newPluginContainerView, 100);
    9190        }
    9291
     
    122121        private void AddConnectionSource(IConnectable source, CryptoLineView conn)
    123122        {
    124             Color color = ColorHelper.getColor((source as ConnectorView).Model.ConnectorType);
     123            Color color = ColorHelper.GetDataColor((source as ConnectorView).Model.ConnectorType);
    125124            conn.Stroke = new SolidColorBrush(color);
    126125            conn.SetBinding(CryptoLineView.StartPointProperty, CreateConnectorBinding(source));
     
    196195            if (e.LeftButton == MouseButtonState.Pressed && selectedPluginContainer != null)
    197196            {
    198                 p = selectedPluginContainer.GetPosition();
    199                 this.selectedPluginContainer.SetPosition(new Point(p.X + Mouse.GetPosition(root).X - previousDragPoint.X, p.Y + Mouse.GetPosition(root).Y - previousDragPoint.Y));
     197                point = selectedPluginContainer.GetPosition();
     198                this.selectedPluginContainer.SetPosition(new Point(point.X + Mouse.GetPosition(root).X - previousDragPoint.X, point.Y + Mouse.GetPosition(root).Y - previousDragPoint.Y));
    200199            }
    201200
  • trunk/CrypPlugins/WorkspaceManager/View/VisualComponents/CryptoLineView.cs

    r1617 r1621  
    6363        {
    6464            this.Model = connectionModel;
    65             Color color = ColorHelper.getColor(connectionModel.ConnectionType);
     65            Color color = ColorHelper.GetDataColor(connectionModel.ConnectionType);
    6666            Stroke = new SolidColorBrush(color);
    6767            StrokeThickness = 2;
Note: See TracChangeset for help on using the changeset viewer.