public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { Color varColor = VariableTypeInspector.GetColorFromType(value as Type); varColor = Color.Multiply(varColor, 0.4f); varColor.A = 153; LinearGradientBrush linearBrush = new LinearGradientBrush(); linearBrush.StartPoint = new Point(0, 0); linearBrush.EndPoint = new Point(0, 1); linearBrush.GradientStops.Add(new GradientStop(varColor, 0)); linearBrush.GradientStops.Add(new GradientStop(Color.FromArgb(153, 0, 0, 0), 0.4)); return(linearBrush); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CreateNamedVar_Executed(object sender, ExecutedRoutedEventArgs e) { NewNamedVarWindow win = new NewNamedVarWindow(); win.Title = "New Named Variable"; win.InputName = "name of the variable"; win.IsValidInputNameCallback = NamedVariableManager.Instance.IsValidName; win.Owner = MainWindow.Instance; if (win.ShowDialog() == false) { return; } NamedVariableManager.Instance.Add( win.InputName, VariableTypeInspector.CreateDefaultValueFromType(Type.GetType(win.InputType))); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return(new SolidColorBrush(VariableTypeInspector.GetColorFromType(value as Type))); }
/// <summary> /// Check if the 2 slot can be connected /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="message_"></param> /// <returns></returns> private bool IsValidConnection(ConnectorViewModel a, ConnectorViewModel b, ref string message_) { bool connectionOk = a.ParentNode != b.ParentNode && a.Type != b.Type; if (connectionOk == true) { //case Variable Input Output if (a.Type == ConnectorType.VariableInputOutput) { connectionOk = b.Type == ConnectorType.VariableInput || b.Type == ConnectorType.VariableOutput; } else if (b.Type == ConnectorType.VariableInputOutput) { connectionOk = a.Type == ConnectorType.VariableInput || a.Type == ConnectorType.VariableOutput; } //case node/variable if (a.Type == ConnectorType.Input || a.Type == ConnectorType.Output) { connectionOk = b.Type == ConnectorType.Input || b.Type == ConnectorType.Output; } else if (b.Type == ConnectorType.Input || b.Type == ConnectorType.Output) { connectionOk = a.Type == ConnectorType.Input || a.Type == ConnectorType.Output; } //TODO : test connection object type //case Variable Output/Variable if (a.Type == ConnectorType.VariableOutput) { return(b.Type == ConnectorType.VariableInputOutput || b.Type == ConnectorType.VariableInput); } else if (b.Type == ConnectorType.VariableOutput) { return(a.Type == ConnectorType.VariableInputOutput || a.Type == ConnectorType.VariableInput); } //case Variable Input/Variable if (a.Type == ConnectorType.VariableInput /* || a.Type == ConnectorType.VariableOutput*/) { //a.AttachedConnections.Count == 1 because the destination connector is already connected connectionOk = b.Type == ConnectorType.VariableInputOutput && a.AttachedConnections.Count == 1; if (connectionOk == false) { message_ = "You can connect only one node into this slot"; } } else if (b.Type == ConnectorType.VariableInput /* || b.Type == ConnectorType.VariableOutput*/) { connectionOk = a.Type == ConnectorType.VariableInputOutput && b.AttachedConnections.Count == 0; if (connectionOk == false) { message_ = "You can connect only one node into this slot"; } } } // TODO : check if obsolete with direct connection ?? // check for variable node connection if (connectionOk == true && ( (a.Type == ConnectorType.VariableInput || a.Type == ConnectorType.VariableOutput || a.Type == ConnectorType.VariableInputOutput) && (b.Type == ConnectorType.VariableInput || b.Type == ConnectorType.VariableOutput || b.Type == ConnectorType.VariableInputOutput) )) { connectionOk = VariableTypeInspector.CheckCompatibilityType(a.SourceSlot.VariableType, b.SourceSlot.VariableType); if (connectionOk == false) { message_ = "You can not connect because the type is different"; } } return(connectionOk); }