public LaunchWindow() { InitializeComponent(); SetupText(); SetupList(); imgLogo.Source = ImageResources.GetImage(ImageResourceList.Logo); }
private AppResourcesLisener() { isDispposing = false; languages = new LanguageResources(); themes = new ThemeResources(); images = new ImageResources(); }
//private int _rtuModes=0; public TreeNodeItemAttachEquViewModel(TreeNodeBaseNode mvvmFather, Wlst.Sr.EquipmentInfoHolding.Model.WjParaBase attachInfomation) { AttInfo = attachInfomation; this.NodeType = TypeOfTabTreeNode.IsTmlParts; //Visi = Visibility.Visible; this._father = mvvmFather; this.IsShowChkTree = Visibility.Collapsed; // Cr.CoreOne.Services.OptionXmlSvr.GetOptionBool(4001, 2, false) //? Visibility.Visible //: Visibility.Collapsed; if (attachInfomation == null) { this.NodeName = "加载出错"; } else { this.NodeName = attachInfomation.RtuName; var running = Wlst.Sr.EquipmentInfoHolding.Services.RunningInfoHold.GetRunInfo(attachInfomation.RtuId); //if (running != null && running.ErrorCount > 0) //{ //this.ImagesIcon = ImageResources.GetEquipmentIcon((int) attachInfomation.RtuModel + 1); //} //else //{ this.ImagesIcon = ImageResources.GetEquipmentIcon((int)attachInfomation.RtuModel); //} this.NodeId = attachInfomation.RtuId; this.Md5 = attachInfomation.DateUpdate; RtuModel = (int)attachInfomation.RtuModel; } }
public ScoreBoard(ImageResources gfx) { Life1 = gfx.biggun.Clone(); Life2 = gfx.biggun.Clone(); Life3 = gfx.biggun.Clone(); score_label.style.color = Color.White; lives_label.style.color = Color.White; score_value.style.color = Color.Green; var left = new IHTMLDiv(score_label, score_value); left.style.Float = IStyle.FloatEnum.left; lives_value.appendChild( Life1, Life2, Life3 ); score_value.style.paddingLeft = "1em"; Life1.style.paddingLeft = "1em"; Life2.style.paddingLeft = "1em"; Life3.style.paddingLeft = "1em"; var right = new IHTMLDiv(lives_label, lives_value); right.style.Float = IStyle.FloatEnum.right; Control.style.fontSize = "22px"; Control.appendChild(left, right); }
System.Windows.Media.Imaging.BitmapImage RetrieveImage(string value) { System.Windows.Media.Imaging.BitmapImage btm = ImageCache.Retrieve(value); if (btm != null) { return(btm); } System.Windows.Controls.Image img3; img3 = new System.Windows.Controls.Image(); IUsdConfiguraitonManager _cfgMgr = AifServiceContainer.Instance.GetService <IUsdConfiguraitonManager>(); if (_cfgMgr != null && _cfgMgr.IsUsdConfigDataReady) { ImageResources _crmWebResource = new ImageResources(_cfgMgr.CrmManagementSvc); System.Windows.Media.Imaging.BitmapImage bm; bm = _crmWebResource.GetImageFromCRMWebResource((string)value); if (bm != null) { ImageCache.Store((string)value, bm); return(bm.Clone()); } else { return(null); } } else { return(null); } }
/// <summary> /// Intializes the windows widgets. /// </summary> private void InitializeWidgets() { mainWindow.Title = title; // We load the icons menuLoadImage.Image = ImageResources.LoadImage("insert-image16"); toolLoadImage.IconWidget = ImageResources.LoadImage("insert-image22"); menuOpenDatabaseManager.Image = ImageResources.LoadImage("database16"); toolDatabase.IconWidget = ImageResources.LoadImage("database22"); // The log view is created logView = new LogView(); expLog.Add(logView); while (recognizingStepsNB.NPages > 0) { recognizingStepsNB.RemovePage(0); } recognizingStepsNB.AppendPage(new InitialStageWidget(this), new Label(InitialStageWidget.WidgetLabel)); mainWindow.ShowAll(); recognizingStepsNB.Page = 0; }
public GameWindow() { InitializeComponent(); SetupText(); grdPopup.Visibility = Visibility.Hidden; imgLogo.Source = ImageResources.GetImage(ImageResourceList.LogoSmall); }
/// <summary> /// Converts the <see cref="sourceValue" /> parameter to the <see cref="destinationType" /> parameter using <see cref="formatProvider" /// /> and <see cref="ignoreCase" /> /// </summary> /// <param name="sourceValue">the value to convert into an instance of <see cref="ImageResources" />.</param> /// <returns> /// an instance of <see cref="ImageResources" />, or <c>null</c> if there is no suitable conversion. /// </returns> public static object ConvertFrom(dynamic sourceValue) { if (null == sourceValue) { return(null); } try { ImageResources.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString()); } catch { // Unable to use JSON pattern } try { return(new ImageResources { Architecture = sourceValue.Architecture, Checksum = ChecksumTypeConverter.ConvertFrom(sourceValue.Checksum), ImageType = sourceValue.ImageType, SourceUri = sourceValue.SourceUri, Version = ImageVersionResourcesTypeConverter.ConvertFrom(sourceValue.Version), }); } catch { } return(null); }
public TreeNodeItemAttachEquViewModel(TreeNodeBaseNode mvvmFather, Wlst.Sr.EquipmentInfoHolding.Model.WjParaBase attachInfomation) { this.NodeType = TypeOfTabTreeNode.IsTmlParts; Visi = Visibility.Visible; this._father = mvvmFather; if (attachInfomation == null) { this.NodeName = "加载出错"; } else { this.NodeName = attachInfomation.RtuName; var running = Wlst.Sr.EquipmentInfoHolding.Services.RunningInfoHold.GetRunInfo(attachInfomation.RtuId); if (running != null && running.ErrorCount > 0) { this.ImagesIcon = ImageResources.GetEquipmentIcon((int )attachInfomation.RtuModel + 1); } else { this.ImagesIcon = ImageResources.GetEquipmentIcon((int)attachInfomation.RtuModel); } this.NodeId = attachInfomation.RtuId; this.Md5 = attachInfomation.DateUpdate; } }
/////////////////////////////////////////////////////////////////////////// public PsdFile() { Version = 1; BaseLayer = new Layer(this); ImageResources = new ImageResources(); Layers = new List<Layer>(); AdditionalInfo = new List<LayerInfo>(); }
/// <summary> /// <c>MainLearnerWindow</c>'s parametriced constructor. /// </summary> /// <param name="parent"> /// The windo's parent window. /// </param> /// <param name="inputDatabase"> /// A database to be loaded upon start. /// </param> /// <param name="inputDatabasePath"> /// The path of the input database. /// </param> /// <param name="inputImage"> /// An image to be learned upon start. /// </param> public MainLearnerWindow(Gtk.Window parent, MathTextDatabase inputDatabase, string inputDatabasePath, Pixbuf inputImage, string inputImageName) { Glade.XML gxml = new Glade.XML(null, "mathtextlearner.glade", "mainWindow", null); gxml.Autoconnect(this); Initialize(); if (parent != null) { mainWindow.Modal = true; mainWindow.TransientFor = parent; } // We try loading the image. if (inputDatabase != null) { // We have to load a database. SetDatabase(inputDatabase); SetTitle(inputDatabasePath); if (inputImage != null) { LoadNewImage(inputImage); } } else if (inputImage != null) { // We haven't specified a database, but want to learn and image, // so we launch the new database wizard, and add that image. NewDatabaseAsisstant assistant = new NewDatabaseAsisstant(mainWindow, inputImage, inputImageName); ResponseType res = assistant.Run(); if (res == ResponseType.Ok) { SetDatabase(assistant.Database); LoadNewImages(assistant.Images); } assistant.Destroy(); } mainWindow.Icon = ImageResources.LoadPixbuf("mathtextlearner16"); }
/// <inheritdoc /> public string GetImageResourceForFeature(T featureBit) { string imageResource = null; if (!ImageResources.TryGetValue(featureBit, out imageResource)) { imageResource = null; } return(imageResource); }
private static Image StarImage(bool Whole) { Image Star = new Image(); Star.Source = ImageResources.GetImage(Whole ? ImageResourceList.Star_Whole : ImageResourceList.Star_Half); Star.Width = STARWIDTH; Star.Height = STARHEIGHT; return(Star); }
private void SetupControl() { imgPitch.ImageSource = ImageResources.GetImage(ImageResourceList.Pitch); // Paging control for formations FormationAdapter fa = new FormationAdapter(); foreach (Formation f in fa.GetFormations()) { FormationPaging.Items.Add(new PagingItem() { ID = f.UniqueID, Name = f.Name }); } // Create empty circles inside the grid // Set the PlayerGridPositions to blanks for (int x = 0; x < GRIDWIDTH; x++) { for (int y = 0; y < GRIDHEIGHT; y++) { // --- Marker symbol --- Markers[x, y] = GraphicUtils.Shirt(); Markers[x, y].VerticalAlignment = VerticalAlignment.Center; Markers[x, y].HorizontalAlignment = HorizontalAlignment.Center; Markers[x, y].AllowDrop = true; Markers[x, y].Drop += new DragEventHandler(Marker_Drop); Markers[x, y].Tag = x.ToString() + "," + y.ToString(); Grid.SetColumn(Markers[x, y], x + 1); Grid.SetRow(Markers[x, y], 8 - y); grdPitch.Children.Add(Markers[x, y]); // --- Text --- MarkerText[x, y] = new TextBlock(); MarkerText[x, y].Text = ""; MarkerText[x, y].Visibility = Visibility.Hidden; MarkerText[x, y].Foreground = Brushes.White; MarkerText[x, y].FontSize = 12; MarkerText[x, y].FontFamily = new FontFamily("Roboto Black"); MarkerText[x, y].VerticalAlignment = VerticalAlignment.Center; MarkerText[x, y].HorizontalAlignment = HorizontalAlignment.Center; Grid.SetColumn(MarkerText[x, y], x + 1); Grid.SetRow(MarkerText[x, y], 8 - y); grdPitch.Children.Add(MarkerText[x, y]); PlayerGridPositions[x, y] = -1; } } }
public EnemyDirectory(ImageResources gfx) { Func <ImageResources.Item, int, EnemyInfo> ctor = (Image, Points) => new EnemyInfo { Image = Image, Points = Points }; this.A = ctor(gfx.aenemy, 4); this.B = ctor(gfx.benemy, 2); this.C = ctor(gfx.cenemy, 1); this.UFO = ctor(gfx.ufo, 10); }
void IPlugin.Accept(IPluginHostServices services) { hostServices = services; menuItem = hostServices.MenuBar.AddMenuItem("&Tools|&Options"); menuItem.Click += menuItem_Click; ImageResources imageResources = new ImageResources(); hostServices.ToolStrip.AddButton("Options", imageResources.GetImage("PropertiesHS.png"), onOptionsButtonClick, "Options"); }
public TreeItemViewModel(TreeItemViewModel mvvmFather, int areaId, object targetInfomation, bool IsGrp, ObservableCollection <TreeItemViewModel> rootChild) { RootChilds = rootChild; IsGroup = IsGrp; AreaId = areaId; if (!IsGrp) { var terminalInfomation = targetInfomation as Wlst.Sr.EquipmentInfoHolding.Model.WjParaBase; if (terminalInfomation == null) { this.NodeName = "加载出错"; } else { this.NodeName = terminalInfomation.RtuName; //this.IconSource = ImageSource.TmlUnConnected; ImagesSource = ImageResources.GetTmlTreeIcon(3); this.NodeType = TreeNodeType.IsTml; this.NodeId = terminalInfomation.RtuId; this.TargetModel = (int )terminalInfomation.RtuModel; } } else { var groupInfomatioin = targetInfomation as GroupItemsInfo.GroupItem; if (groupInfomatioin == null) { this.NodeName = "加载出错"; } else { this.NodeName = groupInfomatioin.GroupName; //this.IconSource = ImageSource.GrpImage; ImagesSource = ImageResources.GroupIcon; this.NodeType = TreeNodeType.IsGrp; this.NodeId = groupInfomatioin.GroupId; this.TargetModel = -1; } } LabNameVisi = Visibility.Visible; TxbNameVisi = Visibility.Hidden; BackUpName = ""; this._father = mvvmFather; _ChildTreeItems = new ObservableCollection <TreeItemViewModel>(); EventPublish.AddEventTokener( Assembly.GetExecutingAssembly().GetName().ToString(), FundEventHandler, FundOrderFilter); }
protected void InitializeWidgets() { store = new NodeStore(typeof(SegmentedNode)); // Creamos el NodeView, podría hacerse en el fichero de Glade, // aunque alguna razón habría por la que se hizo así. treeview = new NodeView(store); treeview.RulesHint = true; treeview.ShowExpanders = true; treeview.AppendColumn("Imagen", new CellRendererText(), "text", 0); CellRendererText cellRenderer = new CellRendererText(); cellRenderer.Xalign = 0.5f; treeview.AppendColumn("Etiqueta", cellRenderer, "text", 1); treeview.AppendColumn("Posición", new CellRendererText(), "text", 2); scrolledtree.Add(treeview); foreach (TreeViewColumn col in treeview) { col.Sizing = TreeViewColumnSizing.Autosize; } // Asignamos el evento para cuando se produzca la selección de un // nodo en el árbol. treeview.NodeSelection.Changed += OnTreeviewSelectionChanged; treeview.ButtonPressEvent += new ButtonPressEventHandler(OnTreeviewButtonPress); imageAreaOriginal = new ImageArea(); imageAreaOriginal.ImageMode = ImageAreaMode.Zoom; frameOriginal.Add(imageAreaOriginal); imageAreaNode = new ImageArea(); imageAreaNode.ImageMode = ImageAreaMode.Zoom; frameNodeActual.Add(imageAreaNode); learnImageItem.Image = ImageResources.LoadImage("database16"); }
void IPlugin.Accept(IPluginHostServices hostServices) { ImageResources imageResources = new ImageResources(); hostServices.ToolStrip.AddButton("Refresh RSS", imageResources.GetImage("page_refresh.gif"), onRefreshRSSButtonClicked, "Refresh"); IPersistenceService persistenceService = hostServices.GetService <IPersistenceService>(); options = persistenceService.RegisterScope("IncidentsRSSReader", UpdatePersistence, options); hostServices.OptionsView.AddProperties(options); hostServices.AddService(incidentsRSSReader); hostServices.AddOnOpenListener(this); }
public InitialStageWidget(MainRecognizerWindow window) : base(window) { Glade.XML gladeXml = new XML("mathtextrecognizer.glade", "initialStageWidgetBase"); gladeXml.Autoconnect(this); this.Add(initialStageWidgetBase); //blackboardModeBtn.NoShowAll = true; blackboardImage.Pixbuf = ImageResources.LoadPixbuf("edu_miscellaneous32"); }
private AppInfoDialog(Window parent, string title, string msg, string logoResource) { Glade.XML gxml = new Glade.XML(null, "gui.glade", "appInfoDialog", null); gxml.Autoconnect(this); appInfoDialog.TransientFor = parent; appInfoDialog.Modal = true; appInfoDialog.Icon = parent.Icon; appInfoDialog.Name = title; appInfoDialog.Comments = msg + "\n\nDesarrollado como proyecto de fin de carrera por:\n\n" + "Luis Román Gutiérrez"; appInfoDialog.Logo = ImageResources.LoadPixbuf(logoResource); }
public void CreateBackground() { Canvas c = new Canvas(); Panel.SetZIndex(c, -9999); Image i = new Image(); i.Stretch = Stretch.Fill; i.Source = ImageResources.GetImage(ImageResourceList.Background); i.Width = this.Width; i.Height = this.Height; Grid.SetColumn(c, 0); Grid.SetRow(c, 2); Grid.SetColumnSpan(c, 6); c.Children.Add(i); grdMain.Children.Add(c); }
/// <summary> /// <see cref="MainRecognizer">'s constructor. /// </summary> public MainRecognizerWindow() { Glade.XML gxml = new Glade.XML(null, "mathtextrecognizer.glade", "mainWindow", null); gxml.Autoconnect(this); this.InitializeWidgets(); Config.RecognizerConfig.Instance.Changed += new EventHandler(OnConfigChanged); this.mainWindow.Icon = ImageResources.LoadPixbuf("mathtextrecognizer48"); OnConfigChanged(this, EventArgs.Empty); }
/// <summary> /// 当分组信息发生变化的时候 增量式重新加载节点 /// One Update terminal informaiton /// Two Update terminal Running information /// </summary> public override void ReUpdate(int updateArgu) { if (updateArgu == 1) { this.UpdateInfosmation(); this.UpdateTmlInfomation(); } if (updateArgu == 11) { if (Wlst.Sr.EquipemntLightFault.Services.TmlErrorStates.IsRtuHasError(this.NodeId)) { this.ImagesIcon = ImageResources.GetEquipmentIcon(RtuModelss + 1); } else { this.ImagesIcon = ImageResources.GetEquipmentIcon(RtuModelss); } } }
/// <summary> /// Inicializa los controles de la ventana. /// </summary> private void Initialize() { mainWindow.Title = title; imageAreaOriginal = new ImageArea(); imageAreaOriginal.ImageMode = ImageAreaMode.Zoom; frameOriginal.Add(imageAreaOriginal); imageAreaProcessed = new ImageArea(); imageAreaProcessed.ImageMode = ImageAreaMode.Zoom; frameProcessed.Add(imageAreaProcessed); logView = new LogView(); expanderLog.Add(logView); // La imagen reducida en la primera columna imagesIV.PixbufColumn = 0; imagesIV.SelectionChanged += new EventHandler(OnImagesIVSelectionChanged); imagesStore = new ListStore(typeof(Gdk.Pixbuf), typeof(Gdk.Pixbuf)); imagesIV.Model = imagesStore; imagesStore.RowInserted += OnImagesStoreRowInserted; imagesStore.RowDeleted += OnImagesStoreRowDeleted; toolNewDatabase.IconWidget = ImageResources.LoadImage("database-new22"); menuDatabase.Image = ImageResources.LoadImage("database-new16"); symbolLabelEditor = new SymbolLabelEditorWidget(); symbolEditorPlaceholder.Add(symbolLabelEditor); labelTooltips = new Tooltips(); mainWindow.ShowAll(); }
/// <summary> /// <c>NewDatabaseAssistant</c>'s constructor. /// </summary> /// <param name="parent"> /// The window this dialog will be modal of. /// </param> public NewDatabaseAsisstant(Window parent) : base(parent, "Asistente de nueva base de datos de caracteres") { databaseStep = new DatabaseTypeStep(this); fileStep = new FileSelectionStep(this); processesStep = new BitmapProcessesStep(this, fileStep.ImagesStore); propertiesStep = new DatabasePropertiesStep(this); this.AddStep(databaseStep); this.AddStep(fileStep); this.AddStep(processesStep); this.AddStep(propertiesStep); foreach (PanelAssistantStep panel in Steps) { panel.StepWidget.SetSizeRequest(500, 300); } this.Window.Icon = ImageResources.LoadPixbuf("database-new16"); }
/// <summary> /// Inicializa los controles del dialogo. /// </summary> private void InitializeWidgets() { // Nos traemos el Glade Glade.XML gladeXML = Glade.XML.FromAssembly("mathtextrecognizer.glade", "databaseManagerDialog", null); gladeXML.Autoconnect(this); databaseManagerDialog.AddActionWidget(closeBtn, ResponseType.Close); // Creamos el modelo de la lista de bases de datos, // para que contenga el tipo de la base de datos, el archivo que // la contiene, y el objecto DatabaseFileInfo asociado. databasesLS = new ListStore(typeof(string), typeof(string), typeof(string), typeof(DatabaseFileInfo)); databasesTV.Model = databasesLS; databasesTV.AppendColumn("Archivo", new CellRendererText(), "text", 0); databasesTV.AppendColumn("Tipo", new CellRendererText(), "text", 1); databasesTV.Columns[0].Sizing = TreeViewColumnSizing.Autosize; databasesTV.Selection.Changed += new EventHandler(OnDatabasesTVSelectionChanged); databaseManagerDialog.Icon = ImageResources.LoadPixbuf("database16"); }
/// <summary> /// ay 2018-6-28 09:51:49 /// 支持jpg jpeg png gif bmp /// </summary> /// <param name="by">图片文件二进制</param> /// <param name="fileName">文件名,要被存储到的地方 绝对路径</param> public static void SaveBitmapImageIntoFile(byte[] by, string fileName) { BitmapImage bitmapImage = null; bitmapImage = ImageResources.ByteArrayToBitmapImage(by, null, null); BitmapEncoder encoder = null; int index = fileName.LastIndexOf('.'); string extion = fileName.Substring( index + 1, fileName.Length - index - 1); extion = extion.ToLower(); switch (extion) { case "jpg": case "jpeg": encoder = new JpegBitmapEncoder(); break; case "png": encoder = new PngBitmapEncoder(); break; case "gif": encoder = new GifBitmapEncoder(); break; case "bmp": encoder = new BmpBitmapEncoder(); break; } encoder.Frames.Add(BitmapFrame.Create(bitmapImage)); using (var fileStream = new System.IO.FileStream(fileName, System.IO.FileMode.Create)) { encoder.Save(fileStream); } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { try { System.Windows.Media.Imaging.BitmapImage btm = ImageCache.Retrieve((string)value); if (btm != null) { return(btm); } System.Windows.Controls.Image img3; img3 = new System.Windows.Controls.Image(); IUsdConfiguraitonManager _cfgMgr = AifServiceContainer.Instance.GetService <IUsdConfiguraitonManager>(); if (_cfgMgr != null && _cfgMgr.IsUsdConfigDataReady) { ImageResources _crmWebResource = new ImageResources(_cfgMgr.CrmManagementSvc); System.Windows.Media.Imaging.BitmapImage bm; bm = _crmWebResource.GetImageFromCRMWebResource((string)value); if (bm != null) { ImageCache.Store((string)value, bm); return(bm.Clone()); } else { return(null); } } else { return(null); } } catch { return(null); } }
public EnemyDirectory(ImageResources gfx) { Func<ImageResources.Item, int, EnemyInfo> ctor = (Image, Points) => new EnemyInfo { Image = Image, Points = Points }; this.A = ctor(gfx.aenemy, 4); this.B = ctor(gfx.benemy, 2); this.C = ctor(gfx.cenemy, 1); this.UFO = ctor(gfx.ufo, 10); }
//Revision: 3636 //Author: zproxy //Date: 22. aprill 2012. a. 11:16:53 //Message: //---- //Added : /examples/java/OutRun4KTemplate //Added : /examples/java/OutRun4KTemplate/OutRun4KTemplate // http://www.digitalinsane.com/archives/2007/01/21/space_invaders/ public SpaceInvaders() { ImageResources gfx = "http://server/"; var overlay = new Overlay(); overlay.BackgroundColor = Color.Black; overlay.MaximumOpacity = 1; overlay.ControlInBack.style.zIndex = 100000; overlay.ControlInFront.style.zIndex = 100001; var view = overlay.ControlInFront; view.style.textAlign = IStyle.TextAlignEnum.center; view.style.SetSize(480, 480); view.style.backgroundColor = Color.Green; view.style.color = Color.White; view.style.fontFamily = IStyle.FontFamilyEnum.Fixedsys; //Native.Document.body.appendChild( // new IHTMLElement(IHTMLElement.HTMLElementEnum.center, // view) // ); //Native.Document.body.style.backgroundColor = Color.Black; // Native.Document.body.style.overflow = IStyle.OverflowEnum.hidden; System.Func <IHTMLDiv> CreateCanvas = delegate { var c = new IHTMLDiv(); c.style.overflow = IStyle.OverflowEnum.hidden; c.style.SetLocation(1, 1, 478, 478); return(c); }; view.style.position = IStyle.PositionEnum.relative; var canvas = CreateCanvas(); var menu = CreateCanvas(); canvas.style.backgroundColor = Color.Black; view.appendChild(canvas, menu); var msg_loading = new IHTMLDiv("loading..."); msg_loading.style.color = Color.Green; menu.appendChild(msg_loading); // at this point we want our images overlay.Visible = true; ScriptCoreLib.JavaScript.Runtime.Timer.DoAsync(overlay.UpdateLocation); // now wait while all images are loaded/complete ((fbool)(() => !gfx.IsComplete)).Trigger( delegate { // loading images is done now. // build the scoreboard var MyEnemyDirectory = new EnemyDirectory(gfx); var board = new ScoreBoard(gfx); board.Control.style.SetLocation(8, 8, 464, 64); canvas.appendChild(board.Control); board.Lives = 2; board.Score = 450; // now we can see lives and score. // ie does not issue keypress for control keys. // scriptcorelib should filter firefox events... // lets show main menu var mmenu = new MainMenu(MyEnemyDirectory, gfx); var gameovermenu = new GameOverMenu(); menu.appendChild(mmenu.Control, gameovermenu.Control); gameovermenu.Visible = false; gameovermenu.Control.style.SetLocation(0, 100, 468, 468 - 100); mmenu.Control.style.SetLocation(0, 64, 468, 468 - 64); mmenu.Visible = true; var Enemy_Ammo = new AmmoInfo { Color = Color.White, Speed = 8 }; var Player = (IHTMLImage)gfx.biggun.Clone(); var Player_Ammo = new AmmoInfo { Color = Color.Green, Speed = -8 }; var Map_Top = 64; var Map_Left = 20; var Map_Right = 450; var Map_Bottom = 470; var Map_Rect = new Rectangle(); Map_Rect.Top = Map_Top; Map_Rect.Left = Map_Left; Map_Rect.Right = Map_Right; Map_Rect.Bottom = Map_Bottom; var Player_Y = 460; var Player_X = 200; var Player_X_step = 8; Action <int> UpdatePlayer = delegate(int v) { Player_X += v; if (Player_X < Map_Left) { Player_X = Map_Left; } if (Player_X > Map_Right) { Player_X = Map_Right; } Player.SetCenteredLocation(Player_X, Player_Y); Player.style.position = IStyle.PositionEnum.absolute; }; Player.Hide(); canvas.appendChild(Player, Player_Ammo.Control, Enemy_Ammo.Control); AmmoInfo[] KnownAmmo = new[] { Player_Ammo, Enemy_Ammo }; var KnownConcrete = new List <Concrete>(); var ConcreteTop = 432; KnownConcrete.AddRange(Concrete.BuildAt(new Point(62 + 120 * 0, ConcreteTop))); KnownConcrete.AddRange(Concrete.BuildAt(new Point(62 + 120 * 1, ConcreteTop))); KnownConcrete.AddRange(Concrete.BuildAt(new Point(62 + 120 * 2, ConcreteTop))); KnownConcrete.AddRange(Concrete.BuildAt(new Point(62 + 120 * 3, ConcreteTop))); foreach (Concrete v in KnownConcrete.ToArray()) { canvas.appendChild(v.Control); } var UFO = new EnemyUnit(MyEnemyDirectory.UFO); var UFO_Direction = 1; UFO.Visible = false; canvas.appendChild(UFO.Control); var EnemyTop = 128; var EnemySpacing = 32; var EnemyCount = 9; var KnownEnemies = new List <EnemyUnit>(); KnownEnemies.AddRange(EnemyUnit.Build(MyEnemyDirectory.A, 20, EnemyTop + 0 * EnemySpacing, EnemyCount, EnemySpacing)); KnownEnemies.AddRange(EnemyUnit.Build(MyEnemyDirectory.B, 20, EnemyTop + 1 * EnemySpacing, EnemyCount, EnemySpacing)); KnownEnemies.AddRange(EnemyUnit.Build(MyEnemyDirectory.B, 20, EnemyTop + 2 * EnemySpacing, EnemyCount, EnemySpacing)); KnownEnemies.AddRange(EnemyUnit.Build(MyEnemyDirectory.C, 20, EnemyTop + 3 * EnemySpacing, EnemyCount, EnemySpacing)); KnownEnemies.AddRange(EnemyUnit.Build(MyEnemyDirectory.C, 20, EnemyTop + 4 * EnemySpacing, EnemyCount, EnemySpacing)); foreach (EnemyUnit v in KnownEnemies.ToArray()) { canvas.appendChild(v.Control); } var HitDamage = 40; var GameTimer = new ScriptCoreLib.JavaScript.Runtime.Timer(); int GangDirection = 1; Action <string> EndGame = delegate { gameovermenu.Visible = true; GameTimer.Stop(); }; #region DoAmmoDamage Func <AmmoInfo, bool> DoAmmoDamage = delegate(AmmoInfo a) { bool hit = false; #region did we hit ufo? if (UFO.Visible) { if (UFO.Bounds.Contains(a.Location)) { board.Score += UFO.Info.Points; UFO.Visible = false; hit = true; } } #endregion #region did we hit player if (Player.Bounds.Contains(a.Location)) { board.Lives--; hit = true; if (board.Lives < 1) { EndGame("Ship destroied"); } } #endregion foreach (Concrete v in KnownConcrete.ToArray()) { if (v.Visible) { if (v.Bounds.Contains(a.Location)) { v.Health -= HitDamage; if (v.Health > 0) { hit = true; } else { v.Visible = false; } } } } foreach (EnemyUnit v in KnownEnemies.ToArray()) { if (v.Visible) { if (v.Bounds.Contains(a.Location)) { v.Visible = false; hit = true; new SpaceInvadersTemplate.HTML.Audio.FromAssets.invaderexplode().play(); board.Score += v.Info.Points; } } } return(hit); }; #endregion var MyRandom = new System.Random(); var mothershiploop = new SpaceInvadersTemplate.HTML.Audio.FromAssets.mothershiploopx { loop = true }; var duh = new IHTMLAudio[] { new SpaceInvadersTemplate.HTML.Audio.FromAssets.duh0(), new SpaceInvadersTemplate.HTML.Audio.FromAssets.duh1(), new SpaceInvadersTemplate.HTML.Audio.FromAssets.duh2(), new SpaceInvadersTemplate.HTML.Audio.FromAssets.duh3(), }; var duh_cycle = duh.ToCyclicAction(a => a.play()); #region EnemyAction Action EnemyAction = delegate { #region create ufo if (!UFO.Visible) { if (MyRandom.NextDouble() < 0.1) { Console.WriteLine("UFO!"); mothershiploop.play(); if (MyRandom.NextDouble() > 0.5) { UFO_Direction = 1; UFO.MoveTo(0, EnemyTop - UFO.Control.height * 2); } else { UFO_Direction = -1; UFO.MoveTo(478, EnemyTop - UFO.Control.height * 2); } UFO.Visible = true; } } #endregion var ev = Enumerable.Where(KnownEnemies.ToArray(), i => i.Visible); if (!Enemy_Ammo.Visible) { var ei = (int)System.Math.Round(MyRandom.NextDouble() * Enumerable.Count(ev)); EnemyUnit et = Enumerable.ElementAt(ev, ei); if (et == null) { System.Console.WriteLine("element at " + ei + " not found"); } else { int ey = Enumerable.Max( from i in ev where i.X == et.X select i.Y // Enumerable.Select(Enumerable.Where(ev, i => i.X == et.X), i => i.Y) ); Enemy_Ammo.MoveTo(et.X, ey + 20); Enemy_Ammo.Visible = true; } } #region MoveAll Action <Point> MoveAll = delegate(Point to) { var ConcreteReached = false; foreach (EnemyUnit v in ev) { var vy = v.Y + to.Y; if (vy > ConcreteTop) { ConcreteReached = true; } v.MoveTo(v.X + to.X, vy); } if (ConcreteReached) { EndGame("The walls have been breached."); } }; #endregion Action MoveAllDown = delegate { MoveAll(new Point(0, 8)); }; duh_cycle(); #region move the gang if (GangDirection > 0) { int ex_max = Enumerable.Max(Enumerable.Select(ev, i => i.X)); // gang goes right if (ex_max >= Map_Rect.Right) { GangDirection = -1; MoveAllDown(); } else { MoveAll(new Point(4, 0)); } } else { int ex_min = Enumerable.Min(Enumerable.Select(ev, i => i.X)); // gang goes left if (ex_min <= Map_Rect.Left) { GangDirection = 1; MoveAllDown(); } else { MoveAll(new Point(-4, 0)); } } #endregion }; #endregion bool GamePaused = false; GameTimer.Tick += delegate { #region only blink while paused if (GamePaused) { if (GameTimer.Counter % 15 == 0) { Player.ToggleVisible(); } return; } #endregion Player.Show(); #region move ufo if (UFO.Visible) { if (UFO_Direction > 0) { UFO.MoveTo(UFO.X + 4, UFO.Y); if (UFO.X > 478 + UFO.Control.width) { UFO.Visible = false; mothershiploop.pause(); } } else { UFO.MoveTo(UFO.X - 4, UFO.Y); if (UFO.X < -UFO.Control.width) { UFO.Visible = false; mothershiploop.pause(); } } } #endregion #region do ammo stuff foreach (AmmoInfo v in KnownAmmo) { if (v.Visible) { var y = v.Y + v.Speed; if (Map_Rect.Contains(new Point(v.X, y))) { // did we hit? if (DoAmmoDamage(v)) { v.Visible = false; } else { v.MoveTo(v.X, y); } } else { v.Visible = false; } } } #endregion var AliveEnemies = Enumerable.Where(KnownEnemies.ToArray(), i => i.Visible); var AliveCount = Enumerable.Count(AliveEnemies); if (AliveCount == 0) { EndGame("Aliens destoried"); return; } if (GameTimer.Counter % (AliveCount / 2) == 0) { EnemyAction(); } }; #region ResetGame Action ResetGame = delegate { mmenu.Visible = false; Player_X = 220; board.Score = 0; board.Lives = 3; Player.Show(); foreach (Concrete v in KnownConcrete.ToArray()) { v.Health = 255; v.Visible = true; } foreach (EnemyUnit v in KnownEnemies.ToArray()) { v.ResetPosition(); v.Visible = true; } EnemyAction(); GameTimer.StartInterval(50); UpdatePlayer(0); }; #endregion Action EgoShoot = delegate { if (!Player_Ammo.Visible) { Player_Ammo.MoveTo(Player_X, Player_Y - 20); new SpaceInvadersTemplate.HTML.Audio.FromAssets.firemissile().play(); Player_Ammo.Visible = true; } }; overlay.ControlInBack.onclick += delegate { if (mmenu.Visible) { ResetGame(); } else { EgoShoot(); } }; double gamma = 0; //Native.window.ondeviceorientation += // eventData => // { // if (eventData.gamma < -50) // gamma = eventData.beta; // else // gamma = eventData.gamma; // }; new ScriptCoreLib.JavaScript.Runtime.Timer( t => { // gamma is the left-to-right tilt in degrees, where right is positive if (gamma < -15) { if (mmenu.Visible) { ResetGame(); } else { UpdatePlayer(-Player_X_step); } } if (gamma > 15) { if (mmenu.Visible) { ResetGame(); } else { UpdatePlayer(Player_X_step); } } } ).StartInterval(100); Native.Document.onkeydown += delegate(IEvent ev) { Console.WriteLine(new { ev.KeyCode }.ToString()); if (mmenu.Visible) { if (ev.IsReturn) { ResetGame(); } return; } else { if (ev.IsEscape) { GameTimer.Stop(); Player.Hide(); mmenu.Visible = true; foreach (AmmoInfo v in KnownAmmo) { v.Visible = false; } foreach (Concrete v in KnownConcrete.ToArray()) { v.Visible = false; } foreach (EnemyUnit v in KnownEnemies.ToArray()) { v.Visible = false; } UFO.Visible = false; gameovermenu.Visible = false; // the animated gifs would stop after escape key ev.preventDefault(); GamePaused = false; } } int key_p = 80; if (ev.KeyCode == key_p) { GamePaused = !GamePaused; } // player shouldn't really move while game is paused // its cheating:) if (GamePaused) { return; } int key_right = 39; int key_left = 37; if (ev.KeyCode == key_left) { UpdatePlayer(-Player_X_step); } else if (ev.KeyCode == key_right) { UpdatePlayer(Player_X_step); } else if (ev.IsSpaceOrEnterKey()) { // the animated gifs would stop after escape key ev.preventDefault(); EgoShoot(); } else { Console.WriteLine(new { UnknownKeyCode = ev.KeyCode }.ToString()); } }; msg_loading.Orphanize(); } , 50); }
public void CanReadImageFromLibrary() { Image image = new ImageResources().GetImage("DeleteHS.png"); Assert.IsNotNull(image); }
public MainMenu(EnemyDirectory MyEnemyDirectory, ImageResources gfx) { Func <string, Color, IHTMLSpan> GetText2 = delegate(string text, Color color) { var s = new IHTMLSpan(text); s.style.color = color; return(s); }; Func <string, Color, string, IHTMLSpan> GetText = delegate(string text, Color color, string size) { var s = GetText2(text, color); s.style.fontSize = size; return(s); }; Control.appendChild( new IHTMLDiv( gfx.cenemy.Clone(), GetText(" SPACE ", Color.White, "48px"), gfx.cenemy.Clone() ) ); Control.appendChild( new IHTMLDiv( gfx.aenemy.Clone(), GetText(" INVADERS ", Color.Green, "48px"), gfx.aenemy.Clone() ) ); Action DrawBreak = delegate { Control.appendChild(new IHTMLBreak()); }; DrawBreak(); Control.appendChild( GetText2("Press ", Color.White), GetText2("enter", Color.Green), GetText2(" to start game", Color.White) ); DrawBreak(); DrawBreak(); Action <EnemyInfo> DrawEnemyInfo = delegate(EnemyInfo e) { Control.appendChild( new IHTMLDiv( e.Image.Clone(), GetText2(" - " + e.Points + " points", Color.White) ) ); }; DrawEnemyInfo(MyEnemyDirectory.A); DrawBreak(); DrawEnemyInfo(MyEnemyDirectory.B); DrawBreak(); DrawEnemyInfo(MyEnemyDirectory.C); DrawBreak(); DrawEnemyInfo(MyEnemyDirectory.UFO); DrawBreak(); DrawBreak(); Control.appendChild( new IHTMLDiv( GetText2("Left/Right arrow", Color.Green), GetText2(" - move, ", Color.White), GetText2("SPACE", Color.Green), GetText2(" - fire", Color.White) ) ); Control.appendChild( new IHTMLDiv( GetText2("Escape", Color.Green), GetText2(" - quit, ", Color.White), GetText2("'p'", Color.Green), GetText2(" - pause", Color.White) ) ); DrawBreak(); DrawBreak(); Control.appendChild( new IHTMLDiv( new IHTMLAnchor("http://zproxy.wordpress.com/2007/03/03/jsc-space-invaders/", "post a comment") ), new IHTMLDiv( new IHTMLAnchor("http://jsc.sourceforge.net", "powered by jsc") ) ); }
public MainMenu(EnemyDirectory MyEnemyDirectory, ImageResources gfx) { Func<string, Color, IHTMLSpan> GetText2 = delegate(string text, Color color) { var s = new IHTMLSpan(text); s.style.color = color; return s; }; Func<string, Color, string, IHTMLSpan> GetText = delegate(string text, Color color, string size) { var s = GetText2(text, color); s.style.fontSize = size; return s; }; Control.appendChild( new IHTMLDiv( gfx.cenemy.Clone(), GetText(" SPACE ", Color.White, "48px"), gfx.cenemy.Clone() ) ); Control.appendChild( new IHTMLDiv( gfx.aenemy.Clone(), GetText(" INVADERS ", Color.Green, "48px"), gfx.aenemy.Clone() ) ); Action DrawBreak = delegate { Control.appendChild(new IHTMLBreak()); }; DrawBreak(); Control.appendChild( GetText2("Press ", Color.White), GetText2("enter", Color.Green), GetText2(" to start game", Color.White) ); DrawBreak(); DrawBreak(); Action<EnemyInfo> DrawEnemyInfo = delegate(EnemyInfo e) { Control.appendChild( new IHTMLDiv( e.Image.Clone(), GetText2(" - " + e.Points + " points", Color.White) ) ); }; DrawEnemyInfo(MyEnemyDirectory.A); DrawBreak(); DrawEnemyInfo(MyEnemyDirectory.B); DrawBreak(); DrawEnemyInfo(MyEnemyDirectory.C); DrawBreak(); DrawEnemyInfo(MyEnemyDirectory.UFO); DrawBreak(); DrawBreak(); Control.appendChild( new IHTMLDiv( GetText2("Left/Right arrow", Color.Green), GetText2(" - move, ", Color.White), GetText2("SPACE", Color.Green), GetText2(" - fire", Color.White) ) ); Control.appendChild( new IHTMLDiv( GetText2("Escape", Color.Green), GetText2(" - quit, ", Color.White), GetText2("'p'", Color.Green), GetText2(" - pause", Color.White) ) ); DrawBreak(); DrawBreak(); Control.appendChild( new IHTMLDiv( new IHTMLAnchor("http://zproxy.wordpress.com/2007/03/03/jsc-space-invaders/", "post a comment") ), new IHTMLDiv( new IHTMLAnchor("http://jsc.sourceforge.net", "powered by jsc") ) ); }