public IDisposable Start(ProfileAction kind, String description) { var itm = new ProfileItem(description); if (!_items.TryGetValue(kind, out ProfileItems elems)) { elems = new ProfileItems(); _items.Add(kind, elems); } elems.Add(itm); return(itm); }
public ActionResult AddAction(ProfileAction value) { value.Date = DateTime.Now; _profileService.AddProfileAction(value, (long)_applicationManager.CurrentUser.ProfileId); var result = new AddActionResult { Profile = _profileService.GetShortProfile((long)_applicationManager.CurrentUser.ProfileId), ProfileAction = _profileService.GetProfileAction(value.ProfileActionId), ProfileActionComments = new List <ProfileActionComment>() }; return(PartialView("LoadAction", result)); }
// INPUT processing of the xml nodes private void ActModeInput(ref ProfileAction pa, XElement xml) { string actModeName = (string)xml.Attribute("ActivationMode"); string multiTap = (string)xml.Attribute("multiTap"); if (string.IsNullOrEmpty(actModeName)) { actModeName = pa.DefActivationMode.Name; // from store } if (string.IsNullOrEmpty(multiTap)) { multiTap = ActivationModes.Instance.MultiTapFor(actModeName).ToString( ); // given by the already collected items } pa.DefActivationMode = new ActivationMode(actModeName, int.Parse(multiTap)); // renew }
private void XInput(ref ProfileAction pa, XElement xml, string input) { ActModeInput(ref pa, xml); if (!string.IsNullOrEmpty(input)) { pa.DefBinding = input; if (pa.DefBinding == " ") { pa.DefBinding = GamepadCls.DisabledInput; } else if (!string.IsNullOrEmpty(pa.DefBinding)) { pa.DefBinding = "xi1_" + pa.DefBinding; // extend with device for mapping use } } }
internal static ProfileActionEntity ToEntity(this ProfileAction profileAction) { ProfileActionEntity profileActionEntity; switch (profileAction.Type.ToString()) { case nameof(ChangeAvatarProfileAction): profileActionEntity = ((ChangeAvatarProfileAction)profileAction).ToEntity(); break; default: // TODO: Throw exception profileActionEntity = null; break; } return(profileActionEntity); }
public ProfileAction AddProfileAction(ProfileAction addAction, long profileId) { if (string.IsNullOrWhiteSpace(addAction?.Text)) { throw new ArgumentException(nameof(addAction)); } if ((profileId != addAction.ProfileWhoId) && (profileId != 0)) { throw new AccessViolationException(nameof(addAction)); } using (var uow = _unitOfWorkFactory.Create()) { uow.ProfileActions.Add(addAction); uow.Complete(); return(addAction); } }
public void RemoveAction(ProfileAction value) { _profileService.RemoveProfileAction(value.ProfileActionId, (long)_applicationManager.CurrentUser.ProfileId); }
public UIView CreateView() { var screenWidth = UIScreen.MainScreen.Bounds.Width; UserInteractionEnabled = true; #region topPanel topView = new UIView(); topView.BackgroundColor = UIColor.Clear; topView.Frame = new CGRect(mainMargin - 5, mainMargin, screenWidth - mainMargin * 2, topViewHeight); avatar = new UIImageView(new CGRect(5, 5, photoSide, photoSide)); avatar.Layer.CornerRadius = photoSide / 2; avatar.ClipsToBounds = true; avatar.UserInteractionEnabled = true; avatar.ContentMode = UIViewContentMode.ScaleAspectFill; avatar.BackgroundColor = UIColor.Clear; powerFrame = new CircleFrame(avatar, new CGRect(0, 0, powerFrameSide, powerFrameSide)); infoView = new UIStackView(); infoView.Axis = UILayoutConstraintAxis.Vertical; infoView.Alignment = UIStackViewAlignment.Fill; infoView.Distribution = UIStackViewDistribution.FillEqually; infoView.Frame = new CGRect(powerFrameSide + topViewSpacing, 0, screenWidth - mainMargin * 2 - (powerFrameSide + topViewSpacing), topViewHeight + 8); userName = new UILabel(); userName.UserInteractionEnabled = false; userName.TextColor = Helpers.Constants.R15G24B30; userName.Font = Helpers.Constants.Semibold20; userName.Lines = 1; userName.LineBreakMode = UILineBreakMode.TailTruncation; userName.BackgroundColor = UIColor.Clear; userLocation = new UILabel(); userLocation.UserInteractionEnabled = false; userLocation.TextColor = Helpers.Constants.R151G155B158; userLocation.Font = Helpers.Constants.Regular14; userLocation.Lines = 1; userLocation.LineBreakMode = UILineBreakMode.TailTruncation; userLocation.BackgroundColor = UIColor.Clear; var topEmptyView = new UIView(); var bottomEmptyView = new UIView(); infoView.AddArrangedSubview(topEmptyView); infoView.AddArrangedSubview(userName); infoView.AddArrangedSubview(userLocation); infoView.AddArrangedSubview(bottomEmptyView); topView.AddSubview(powerFrame); topView.AddSubview(infoView); AddSubview(topView); #endregion attributedLabel = new TTTAttributedLabel(); attributedLabel.Lines = 0; attributedLabel.EnabledTextCheckingTypes = NSTextCheckingType.Link; var prop = new NSDictionary(); attributedLabel.LinkAttributes = prop; attributedLabel.ActiveLinkAttributes = prop; attributedLabel.Delegate = new TTTAttributedLabelCustomDelegate(); at = new NSMutableAttributedString(); followButton = new UIButton(); followButton.BackgroundColor = UIColor.Clear; AddSubview(followButton); followProgress = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.Gray); followProgress.HidesWhenStopped = false; followProgress.StartAnimating(); AddSubview(followProgress); #region originality originalityContainer = new UIView(); originalityContainer.BackgroundColor = Helpers.Constants.R250G250B250; originalityContainer.Layer.CornerRadius = 10; originalityLabel = new UILabel(); originalityLabel.UserInteractionEnabled = false; //originalityLabel.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.Originality); originalityLabel.TextColor = UIColor.Black; originalityLabel.Font = Helpers.Constants.Regular14; originalityLabel.Lines = 1; originalityLabel.LineBreakMode = UILineBreakMode.TailTruncation; originality = new UILabel(); originality.UserInteractionEnabled = false; originality.Text = "100%"; originality.TextColor = Helpers.Constants.R255G34B5; originality.Font = Helpers.Constants.Semibold14; originality.Lines = 1; originalityContainer.AddSubview(originalityLabel); originalityContainer.AddSubview(originality); //contentView.AddSubview(originalityContainer); #endregion #region stats statsView = new UIStackView(); statsView.Axis = UILayoutConstraintAxis.Horizontal; statsView.Alignment = UIStackViewAlignment.Fill; statsView.Distribution = UIStackViewDistribution.Fill; statsView.TranslatesAutoresizingMaskIntoConstraints = false; photos = new UIButton(); following = new UIButton(); followers = new UIButton(); var emptySpace = new UIView(); var firstSpacing = new UIView(); var secondSpacing = new UIView(); statsView.AddArrangedSubview(photos); statsView.AddArrangedSubview(firstSpacing); statsView.AddArrangedSubview(following); statsView.AddArrangedSubview(secondSpacing); statsView.AddArrangedSubview(followers); statsView.AddArrangedSubview(emptySpace); statsContainer = new UIView(); statsContainer.AddSubview(statsView); AddSubview(statsContainer); #endregion #region balance balanceContainer = new UIView(); balanceContainer.UserInteractionEnabled = true; var topSeparator = new UIView(); var bottomSeparator = new UIView(); topSeparator.BackgroundColor = bottomSeparator.BackgroundColor = Helpers.Constants.R245G245B245; var balanceImage = new UIImageView(); balanceImage.Image = UIImage.FromBundle("ic_balance"); var balanceLabel = new UILabel(); balanceLabel.UserInteractionEnabled = false; balanceLabel.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.AccountBalance); balanceLabel.TextColor = UIColor.Black; balanceLabel.Font = Helpers.Constants.Regular14; balanceLabel.Lines = 1; balance = new UILabel(); balance.UserInteractionEnabled = false; balance.TextColor = Helpers.Constants.R255G34B5; balance.TextAlignment = UITextAlignment.Right; balance.Font = Helpers.Constants.Semibold14; balance.Lines = 1; var balanceArrow = new UIImageView(); balanceArrow.Image = UIImage.FromBundle("ic_forward"); balanceContainer.AddSubview(topSeparator); balanceContainer.AddSubview(bottomSeparator); balanceContainer.AddSubview(balanceImage); balanceContainer.AddSubview(balanceLabel); balanceContainer.AddSubview(balanceArrow); balanceContainer.AddSubview(balance); UITapGestureRecognizer balanceTap = new UITapGestureRecognizer(() => { ProfileAction?.Invoke(ActionType.Balance); }); balanceContainer.AddGestureRecognizer(balanceTap); //#if DEBUG AddSubview(balanceContainer); //#endif #endregion AddSubview(bottomSeparator); #region constraints /* * originalityLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Left, extraMargin); * originalityLabel.AutoAlignAxis(ALAxis.Horizontal, originalityContainer); * originality.AutoPinEdgeToSuperviewEdge(ALEdge.Right, extraMargin); * originality.AutoAlignAxis(ALAxis.Horizontal, originalityContainer); */ statsView.AutoPinEdgesToSuperviewEdges(); topSeparator.AutoSetDimension(ALDimension.Height, 1); topSeparator.AutoPinEdgeToSuperviewEdge(ALEdge.Top); topSeparator.AutoPinEdgeToSuperviewEdge(ALEdge.Left); topSeparator.AutoPinEdgeToSuperviewEdge(ALEdge.Right); bottomSeparator.AutoSetDimension(ALDimension.Height, 1); bottomSeparator.AutoPinEdgeToSuperviewEdge(ALEdge.Left); bottomSeparator.AutoPinEdgeToSuperviewEdge(ALEdge.Right); bottomSeparator.AutoPinEdgeToSuperviewEdge(ALEdge.Bottom); followProgress.AutoAlignAxis(ALAxis.Horizontal, followButton); followProgress.AutoAlignAxis(ALAxis.Vertical, followButton); //#if DEBUG balanceImage.AutoSetDimensionsToSize(new CGSize(10, 10)); balanceImage.AutoPinEdgeToSuperviewEdge(ALEdge.Left, mainMargin); balanceImage.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal); balanceLabel.AutoPinEdge(ALEdge.Left, ALEdge.Right, balanceImage, 20); balanceLabel.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal); balanceArrow.AutoSetDimensionsToSize(new CGSize(6, 10)); balanceArrow.AutoPinEdgeToSuperviewEdge(ALEdge.Right, mainMargin); balanceArrow.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal); balance.AutoPinEdgeToSuperviewEdge(ALEdge.Right, 55); balance.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal); //#endif firstSpacing.AutoSetDimension(ALDimension.Width, 48); secondSpacing.AutoSetDimension(ALDimension.Width, 48); #endregion return(this); }
private void SetupStats() { var buttonsAttributes = new UIStringAttributes { Font = Helpers.Constants.Semibold20, ForegroundColor = Helpers.Constants.R15G24B30, }; var textAttributes = new UIStringAttributes { Font = Helpers.Constants.Regular12, ForegroundColor = Helpers.Constants.R151G155B158, }; NSMutableAttributedString photosString = new NSMutableAttributedString(); photosString.Append(new NSAttributedString(_userData.PostCount.CounterFormat(), buttonsAttributes)); photosString.Append(new NSAttributedString(Environment.NewLine)); photosString.Append(new NSAttributedString("Photos", textAttributes)); NSMutableAttributedString followingString = new NSMutableAttributedString(); followingString.Append(new NSAttributedString(_userData.FollowingCount.CounterFormat(), buttonsAttributes)); followingString.Append(new NSAttributedString(Environment.NewLine)); followingString.Append(new NSAttributedString("Following", textAttributes)); NSMutableAttributedString followersString = new NSMutableAttributedString(); followersString.Append(new NSAttributedString(_userData.FollowersCount.CounterFormat(), buttonsAttributes)); followersString.Append(new NSAttributedString(Environment.NewLine)); followersString.Append(new NSAttributedString("Followers", textAttributes)); photos.TitleLabel.LineBreakMode = UILineBreakMode.WordWrap; photos.TitleLabel.TextAlignment = UITextAlignment.Left; photos.SetAttributedTitle(photosString, UIControlState.Normal); following.TitleLabel.LineBreakMode = UILineBreakMode.WordWrap; following.TitleLabel.TextAlignment = UITextAlignment.Left; following.SetAttributedTitle(followingString, UIControlState.Normal); followers.TitleLabel.LineBreakMode = UILineBreakMode.WordWrap; followers.TitleLabel.TextAlignment = UITextAlignment.Left; followers.SetAttributedTitle(followersString, UIControlState.Normal); UITapGestureRecognizer followTap = new UITapGestureRecognizer(() => { ProfileAction?.Invoke(ActionType.Follow); }); followButton.AddGestureRecognizer(followTap); UITapGestureRecognizer followersTap = new UITapGestureRecognizer(() => { ProfileAction?.Invoke(ActionType.Followers); }); followers.AddGestureRecognizer(followersTap); UITapGestureRecognizer followingTap = new UITapGestureRecognizer(() => { ProfileAction?.Invoke(ActionType.Following); }); following.AddGestureRecognizer(followingTap); UITapGestureRecognizer avatarTap = new UITapGestureRecognizer(() => { ProfileAction?.Invoke(ActionType.ProfilePower); }); avatar.AddGestureRecognizer(avatarTap); }
public void RegisterAction(ProfileAction p) { switch (p) { case ProfileAction.RegisterTarget: xp = xp + 100; ap = ap + 100; break; case ProfileAction.ReviseTarget: xp = xp + 100; ap = ap + 100; break; case ProfileAction.TargetUsed: xp = xp + 300; ap = ap + 300; break; case ProfileAction.RegisterShortNote: xp = xp + 100; rp = rp + 100; break; case ProfileAction.RegisterNote: xp = xp + 500; rp = rp + 500; break; case ProfileAction.RegisterArticle: xp = xp + 1000; rp = rp + 1000; break; case ProfileAction.ShortNoteApproved: xp = xp + 100; rp = rp + 100; break; case ProfileAction.NoteApproved: xp = xp + 500; rp = rp + 500; break; case ProfileAction.ArticleApproved: xp = xp + 1000; rp = rp + 1000; break; case ProfileAction.VoteTarget: xp = xp + 10; ap = ap + 10; break; case ProfileAction.ArticlePublishedInVideo: xp = xp + 2000; rp = rp + 2000; break; case ProfileAction.ReviseArticle: xp = xp + 100; rp = rp + 100; break; case ProfileAction.VoteArticle: xp = xp + 20; rp = rp + 20; break; } }
/// <summary> /// Read all from an Action XElement /// </summary> /// <param name="action">The action XElement</param> /// <returns>True if successfull</returns> private bool ReadAction(XElement action) { /* A variety exists here... * <action name="v_eject_cinematic" onPress="0" onHold="1" onRelease="1" keyboard="ralt+l" xboxpad="shoulderl+shoulderr+y" joystick=" " /> * <action name="v_exit" onPress="1" onHold="0" onRelease="1" multiTap="1" multiTapBlock="1" pressTriggerThreshold="1.0" releaseTriggerThreshold="-1" releaseTriggerDelay="0" keyboard="f" xboxpad="y" UILabel="@ui_CIExit" UIDescription="@ui_CIExitDesc" > * <joystick ActivationMode="press" input=" " /> * </action> * <action name="v_throttle_100" onPress="1" xboxpad=" " joystick=" " UILabel="@ui_CIThrottleMax" UIDescription="@ui_CIThrottleMaxDesc" > * <xboxpad multiTap="2" input="thumbl_up" /> * <keyboard multiTap="2" input=" " /> * </action> * * <action name="v_target_deselect_component" ActivationMode="delayed_press" pressTriggerThreshold="0.75" joystick="" > * <keyboard > * <inputdata input="lbracket" /> * <inputdata input="rbracket" /> * </keyboard> * </action> * */ log.Debug("DProfileReader.ReadAction - Entry"); // a complete actionmap arrives here bool retVal = true; string name = (string)action.Attribute("name"); string uiLabel = (string)action.Attribute("UILabel"); if (string.IsNullOrEmpty(uiLabel)) { uiLabel = name; // subst if not found in Action node } SCUiText.Instance.Add(name, uiLabel); // Register item for translation // prep all kinds var jAC = new ProfileAction( ) { Name = name, UILabel = uiLabel, DevID = Act.DevTag(JoystickCls.DeviceClass) }; var kAC = new ProfileAction( ) { Name = name, UILabel = uiLabel, DevID = Act.DevTag(KeyboardCls.DeviceClass) }; var mAC = new ProfileAction( ) { Name = name, UILabel = uiLabel, DevID = Act.DevTag(MouseCls.DeviceClass) }; var xAC = new ProfileAction( ) { Name = name, UILabel = uiLabel, DevID = Act.DevTag(GamepadCls.DeviceClass) }; // process element items JInput(ref jAC, action, (string)action.Attribute(JoystickCls.DeviceClass)); KInput(ref kAC, action, (string)action.Attribute(KeyboardCls.DeviceClass)); MInput(ref mAC, action, (string)action.Attribute(MouseCls.DeviceClass)); XInput(ref xAC, action, (string)action.Attribute(GamepadCls.DeviceClass)); // then nested ones - they may or may not exist from the initial scan foreach (XElement l1action in action.Elements( )) { // comes with the name of the device class switch (l1action.Name.LocalName) { case JoystickCls.DeviceClass: { JInput(ref jAC, l1action, (string)l1action.Attribute("input")); // may have attributed ones foreach (XElement l2action in l1action.Elements( )) { if (l2action.Name.LocalName == "inputdata") { JInput(ref jAC, l2action, (string)l2action.Attribute("input")); // or in the inputdata nesting } } } break; case KeyboardCls.DeviceClass: { KInput(ref kAC, l1action, (string)l1action.Attribute("input")); // may have attributed ones foreach (XElement l2action in l1action.Elements( )) { if (l2action.Name.LocalName == "inputdata") { KInput(ref kAC, l2action, (string)l2action.Attribute("input")); // or in the inputdata nesting } } } break; case MouseCls.DeviceClass: { MInput(ref mAC, l1action, (string)l1action.Attribute("input")); // may have attributed ones foreach (XElement l2action in l1action.Elements( )) { if (l2action.Name.LocalName == "inputdata") { MInput(ref mAC, l2action, (string)l2action.Attribute("input")); // or in the inputdata nesting } } } break; case GamepadCls.DeviceClass: { XInput(ref xAC, l1action, (string)l1action.Attribute("input")); // may have attributed ones foreach (XElement l2action in l1action.Elements( )) { if (l2action.Name.LocalName == "inputdata") { XInput(ref xAC, l2action, (string)l2action.Attribute("input")); // or in the inputdata nesting } } } break; default: break; } } if (!string.IsNullOrEmpty(jAC.DefBinding)) { m_currentMap.Add(jAC); // finally add it to the current map if it was bound } if (!string.IsNullOrEmpty(kAC.DefBinding)) { m_currentMap.Add(kAC); // finally add it to the current map if it was bound } if (!string.IsNullOrEmpty(mAC.DefBinding)) { m_currentMap.Add(mAC); // finally add it to the current map if it was bound } if (!string.IsNullOrEmpty(xAC.DefBinding)) { m_currentMap.Add(xAC); // finally add it to the current map if it was bound } return(retVal); }
public IDisposable Start(ProfileAction kind, String description) { return(null); }
public ProfileRequest(NodeInfo nodeInfo, ProfileAction action) : this() { this.NodeInfo = nodeInfo; this.Action = action; }
/// <summary> /// Assumes to be in an action element /// retrieves the attributes and collects the various control=binding pairs /// </summary> /// <param name="xr">An XML reader @ StartElement</param> private void CollectActions(Dictionary <string, string> attr) { //first find an ActivationMode if there is - applies to all actions string actModeName = ActivationMode.Default.Name; string multiTap = "0"; // this can be an Activation Mode OR a multitap // if there is an activationMode the multiTap remains 0 // if no ActivationMode is given, multitap is 1 or may be 2... if (attr.ContainsKey("ActivationMode")) { actModeName = attr["ActivationMode"]; multiTap = ActivationModes.Instance.MultiTapFor(actModeName).ToString( ); // given by the already collected items } else { // name remains default - we handle multiTaps only here multiTap = "1"; // default if not changed in the action to may be 2 or so.. if (attr.ContainsKey("multiTap")) { multiTap = attr["multiTap"]; } } ActivationMode actMode = new ActivationMode(actModeName, int.Parse(multiTap)); // should be a valid ActivationMode for this action // we collect actions for each input ie for K,J,X and M if (attr.ContainsKey("joystick")) { ProfileAction ac = new ProfileAction( ); ac.name = attr["name"]; ac.devID = "J"; ac.defBinding = attr["joystick"]; ac.defActivationMode = actMode; if (ac.defBinding == " ") { ac.defBinding = Joystick.JoystickCls.BlendedInput; m_currentMap.Add(ac); // finally add it to the current map if it was bound } else if (!String.IsNullOrEmpty(ac.defBinding)) { ac.defBinding = "js1_" + ac.defBinding; m_currentMap.Add(ac); // finally add it to the current map if it was bound } } if (attr.ContainsKey("keyboard")) { ProfileAction ac = new ProfileAction( ); ac.name = attr["name"]; ac.devID = "K"; ac.defBinding = attr["keyboard"]; ac.defActivationMode = actMode; if (ac.defBinding == " ") { ac.defBinding = Keyboard.KeyboardCls.BlendedInput; m_currentMap.Add(ac); // finally add it to the current map if it was bound } else if (!String.IsNullOrEmpty(ac.defBinding)) { ac.defBinding = "kb1_" + ac.defBinding; m_currentMap.Add(ac); // finally add it to the current map if it was bound } } if (attr.ContainsKey("mouse")) // 20151220BM: add mouse device (from AC 2.0 defaultProfile usage) { ProfileAction ac = new ProfileAction( ); ac.name = attr["name"]; ac.devID = "M"; ac.defBinding = attr["mouse"]; ac.defActivationMode = actMode; if (ac.defBinding == " ") { ac.defBinding = Mouse.MouseCls.BlendedInput; m_currentMap.Add(ac); // finally add it to the current map if it was bound } else if (!String.IsNullOrEmpty(ac.defBinding)) { ac.defBinding = "mo1_" + ac.defBinding; m_currentMap.Add(ac); // finally add it to the current map if it was bound } } if (attr.ContainsKey("xboxpad")) { ProfileAction ac = new ProfileAction( ); ac.name = attr["name"]; ac.devID = "X"; ac.defBinding = attr["xboxpad"]; ac.defActivationMode = actMode; if (ac.defBinding == " ") { ac.defBinding = Gamepad.GamepadCls.BlendedInput; m_currentMap.Add(ac); // finally add it to the current map if it was bound } else if (!String.IsNullOrEmpty(ac.defBinding)) { ac.defBinding = "xi1_" + ac.defBinding; m_currentMap.Add(ac); // finally add it to the current map if it was bound } } if (attr.ContainsKey("ps3pad")) { // ignore } }
public IDisposable Start(ProfileAction kind, string description) { // TODO: return(null); }