public PublishedApplication[] getApplication(Credentials user) { PublishedApplication[] apps = null; string clientName = ""; if (ApplyDefaultClientName) { clientName = user.UserName; clientName = PrefixClientName + "_" + clientName.Replace('\\', '_'); } apps = service.GetApplicationsByCredentials(user, clientName, "", new string[] { "defaults" }, new string[] { "all" }, new string[] { "all" }); for (int i = 0; i < apps.Length; i++) { if (IconsManager.CheckLargeIcon(apps[i].IconFileName, IconsExpirationPeriod)) { apps[i].LargeIcon = apps[i].IconFileName; } if (IconsManager.CheckSmallIcon(apps[i].IconFileName, IconsExpirationPeriod)) { apps[i].SmallIcon = apps[i].IconFileName; } } return(apps); }
private void UpdateApplicationsList(ApplicationLog applicationLog, DataRowAction action) { if (applicationLog == null) { return; } string activeTime = null; string caption = null; if (action == DataRowAction.Add || action == DataRowAction.Change) { TimeSpan active = new TimeSpan(0, 0, applicationLog.ActiveTime); activeTime = ViewHelper.TimeSpanToTimeString(active); caption = applicationLog.Caption; } foreach (TreeListViewItem logItem in this.taskList.Items) { if (((Log)logItem.Tag).Id == applicationLog.TaskLogId) { if (action == DataRowAction.Add) { TreeListViewItem lvi = new TreeListViewItem(caption, new string[] { activeTime, "", applicationLog.Id.ToString(CultureInfo.InvariantCulture) }); lvi.Tag = applicationLog; lvi.ImageIndex = IconsManager.GetIconFromFile(applicationLog.ApplicationFullPath); logItem.Items.Add(lvi); } else { for (int i = 0; i < logItem.Items.Count; i++) { TreeListViewItem appItem = logItem.Items[i]; if (((ApplicationLog)appItem.Tag).Id == applicationLog.Id) { if (action == DataRowAction.Change) { appItem.Tag = applicationLog; appItem.SubItems[TaskDescriptionHeader.Index].Text = caption; appItem.SubItems[DurationTaskHeader.Index].Text = activeTime; return; } if (action == DataRowAction.Delete) { logItem.Items.RemoveAt(i); return; } } } } } } }
private static SplashForm splash;// = new SplashForm(); internal static void Launch() { Application.CurrentCulture = CultureInfo.InvariantCulture; Application.EnableVisualStyles(); //Application.SetCompatibleTextRenderingDefault(false); splash = new SplashForm(); splash.Show(); Timer timer = new Timer(); //Configure this timer to restart each second ( 1000 millis) timer.Interval = 1000; timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); timer.Start(); //splash.Refresh(); //Application.DoEvents(); Application.DoEvents(); MainModule.Initialize("data"); splash.SetLoadProgress(50); splash.Refresh(); Application.DoEvents(); UpdaterHelper.UpdateInfo info; info = UpdaterHelper.CheckFromUpdates(); Application.DoEvents(); if (info.UpdateAvailable) { UpdateForm updateForm; updateForm = new UpdateForm(info); updateForm.ShowDialog(); Application.DoEvents(); } splash.SetLoadProgress(60); splash.Refresh(); Application.DoEvents(); IconsManager.Initialize(); Application.DoEvents(); MainForm main = new MainForm(); //if (runSingleInstance) //{ // main.HandleCreated += new EventHandler(main_HandleCreated); //} GC.Collect(); timer.Stop(); timer.Close(); splash.SetLoadProgress(100); splash.Refresh(); Application.DoEvents(); splash.Close(); splash = null; Application.DoEvents(); Application.Run(main); } //Launch
// Update is called once per frame void Update() { if (isTakeSinkable && Input.GetMouseButtonDown(0)) { Vector3 clickPos = GetPosition(); Debug.Log(clickPos); Debug.Log(Camera.main.transform.position); if (!ClickInGameZone(clickPos)) { return; } SinkableGenerator.GetI().Generate(clickPos, sinkableID); IconsManager.GetI().BlockIcon(sinkableID); isTakeSinkable = false; } }
private void GetTaskDetails(TaskStatisticsResult result) { try { this.applicationsList.BeginUpdate(); this.applicationsList.Items.Clear(); int appActiveTime = 0; foreach (ApplicationSummary applicationsSummaryRow in result.AppsSummaryList) { appActiveTime += (int)applicationsSummaryRow.TotalActiveTime; } foreach (ApplicationSummary applicationsSummaryRow in result.AppsSummaryList) { TimeSpan active = new TimeSpan(0, 0, (int)applicationsSummaryRow.TotalActiveTime); string activeTime = ViewHelper.TimeSpanToTimeString(active); double percent = 0; if (appActiveTime > 0) { percent = applicationsSummaryRow.TotalActiveTime / appActiveTime; } TreeListViewItem lvi = new TreeListViewItem(applicationsSummaryRow.Name, new string[] { activeTime, percent.ToString("0.0%", CultureInfo.InvariantCulture), applicationsSummaryRow.TaskId.ToString(CultureInfo.InvariantCulture) }); lvi.ImageIndex = IconsManager.GetIconFromFile(applicationsSummaryRow.ApplicationFullPath); this.applicationsList.Items.Add(lvi); } AppsActiveTimeValue.Text = ViewHelper.TimeSpanToTimeString(new TimeSpan(0, 0, appActiveTime)); } finally { this.applicationsList.EndUpdate(); SetReadyState(); } }
private CustomizationSection BuildMenu( XmlDocument kojtoCadMenuDefinition, Dictionary <CommandMethodAttribute, MethodInfo> commandsAndMethodsDictionary) { // rebuild the new cui // Create a customization section for our partial menu CustomizationSection kojtoCui = new CustomizationSection(); kojtoCui.MenuGroupName = Settings.Default.appName; // add a menu group var kojtoCadMacroGroup = new MacroGroup(kojtoCui.MenuGroupName, kojtoCui.MenuGroup); foreach (XmlNode toolBarDefinition in kojtoCadMenuDefinition.DocumentElement.ChildNodes) { var toolBar = new Toolbar(toolBarDefinition.Attributes["name"].Value, kojtoCui.MenuGroup); toolBar.ToolbarOrient = ToolbarOrient.right; toolBar.ToolbarVisible = ToolbarVisible.show; foreach (XmlNode buttonDefinition in toolBarDefinition) { foreach (KeyValuePair <CommandMethodAttribute, MethodInfo> commandAndMethod in commandsAndMethodsDictionary) { CommandMethodAttribute commandMethodAttribute = commandAndMethod.Key; MethodInfo method = commandAndMethod.Value; if (method.Name.Length <= "Start".Length) { continue; } string methodName = method.Name.Substring(0, method.Name.Length - "Start".Length); if (!methodName.Equals(buttonDefinition.Attributes["methodName"].Value, StringComparison.InvariantCultureIgnoreCase)) { continue; } MenuMacro menuMacro = new MenuMacro( kojtoCadMacroGroup, buttonDefinition.InnerText, commandMethodAttribute.GlobalName, method.Name); string smallImage = ""; string mediumImage = ""; ; try { smallImage = IconsManager.GetIconFile( commandAndMethod.Value.Name.Replace("Start", ""), IconSize.Small); mediumImage = IconsManager.GetIconFile( commandAndMethod.Value.Name.Replace("Start", ""), IconSize.Medium); menuMacro.macro.SmallImage = smallImage; menuMacro.macro.LargeImage = mediumImage; // The var toolBarButton is not assigned to anything because it needs only to be instantiated in order appear in the toolbar var toolBarButton = new ToolbarButton( menuMacro.ElementID, buttonDefinition.InnerText, toolBar, -1); } catch (System.Exception exception) { Logger.Error(Resources.ErrorCreatingToolbarButton, exception); } } } } return(kojtoCui); }
// Use this for initialization void Start() { instance = this; }
private void PopulateToolbarItems() { var cuiFile = DirectoriesAndFiles.BcadCuiFile; var cuiFileName = new FileInfo(cuiFile).Name.Replace(new FileInfo(cuiFile).Extension, string.Empty); var app = Application.AcadApplication as AcadApplication; if (app == null) { MessageBox.Show("App was null!", "E R R O R", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var menuGroups = app.MenuGroups; var myGroup = menuGroups.GetMenuGroupByName(cuiFileName) ?? menuGroups.Load(cuiFile); var toolbars = myGroup.Toolbars; var commandMethods = GetCommandMethodsFromCurrentAssembly().Where(x => x.Value.Name.Length >= "Start".Length).ToArray(); var documentElement = MenuSchemaProvider.GetMenuSchemaFile().DocumentElement; if (documentElement != null) { var toolbarDefinitions = documentElement.ChildNodes; foreach (XmlNode toolBarDefinition in toolbarDefinitions) { if (toolBarDefinition.Attributes == null) { MessageBox.Show("XML file - toolbar name!", "E R R O R", MessageBoxButtons.OK, MessageBoxIcon.Error); continue; } var toolbarName = toolBarDefinition.Attributes["name"].Value; var toolbar = toolbars.GetToolbarByName(toolbarName); if (toolbar == null) { toolbar = toolbars.Add(toolbarName); toolbar.Dock(AcToolbarDockStatus.acToolbarDockRight); } foreach (XmlNode buttonDefinition in toolBarDefinition) { if (buttonDefinition.Attributes == null) { MessageBox.Show("XML file - method name!", "E R R O R", MessageBoxButtons.OK, MessageBoxIcon.Error); continue; } var buttonName = buttonDefinition.Attributes["methodName"].Value; var toolbarItem = toolbar.GetToolbarItemByName(buttonName); if (toolbarItem == null) { var buttonMethod = commandMethods.FirstOrDefault( x => x.Value.Name.Substring(0, x.Value.Name.Length - "Start".Length) .Equals(buttonName, StringComparison.InvariantCultureIgnoreCase)); toolbarItem = toolbar.AddToolbarButton(-1, buttonName, buttonDefinition.InnerText, buttonMethod.Key.GlobalName); var smallIcon = IconsManager.GetIconFile(buttonMethod.Value.Name.Replace("Start", ""), IconSize.Small); var largeIcon = IconsManager.GetIconFile(buttonMethod.Value.Name.Replace("Start", ""), IconSize.Large); if (!File.Exists(smallIcon) || !File.Exists(largeIcon)) { MessageBox.Show("Icon not found!", "E R R O R", MessageBoxButtons.OK, MessageBoxIcon.Error); continue; } toolbarItem.SetBitmaps(smallIcon, largeIcon); } } } } myGroup.Save(AcMenuFileType.acMenuFileSource); }
public void ProcessIcons(Credentials user, WebServiceAPI service) { var watch = Stopwatch.StartNew(); Logger.Default.Info(LogLocation, string.Format("LoadWebPartView: Start creating icons {0}", DateTime.Now)); PublishedApplication[] apps = Page.Session["PublishedApps"] as PublishedApplication[]; var iconsApp = service.GetApplicationsByCredentialsEx(user, "", "", new string[] { "icon-info" }, new string[] { "all" }, new string[] { "all" }); if ((apps != null) && (iconsApp != null)) { for (int i = 0; i < apps.Length; i++) { apps[i].LargeIcon = ""; apps[i].SmallIcon = ""; try { var iconInfoApp = iconsApp.FirstOrDefault(x => x.Item.InternalName.Equals(apps[i].Item.InternalName, StringComparison.OrdinalIgnoreCase)); if (iconInfoApp != null) { if (!IconsManager.CheckLargeIcon(apps[i].IconFileName, IconsExpirationPeriod)) { apps[i].LargeIcon = service.GetApplicationIcon(iconInfoApp.Item, 32, 32, "ICO", user, apps[i].FarmName); if (apps[i].LargeIcon != null) { IconsManager.CreateLargeIcon(apps[i]); apps[i].LargeIcon = apps[i].IconFileName; } } else { apps[i].LargeIcon = apps[i].IconFileName; } if (!IconsManager.CheckSmallIcon(apps[i].IconFileName, IconsExpirationPeriod)) { apps[i].SmallIcon = service.GetApplicationIcon(iconInfoApp.Item, 16, 32, "ICO", user, apps[i].FarmName); if (apps[i].SmallIcon == null) { apps[i].SmallIcon = service.GetApplicationIcon(iconInfoApp.Item, 8, 32, "ICO", user, apps[i].FarmName); } if (apps[i].SmallIcon == null) { apps[i].SmallIcon = service.GetApplicationIcon(iconInfoApp.Item, 4, 32, "ICO", user, apps[i].FarmName); } if (apps[i].SmallIcon != null) { IconsManager.CreateSmallIcon(apps[i]); apps[i].SmallIcon = apps[i].IconFileName; } } else { apps[i].SmallIcon = apps[i].IconFileName; } } } catch (Exception ex) { Logger.Default.Error(LogLocation, "User - " + user.UserName + " ; Error = " + ex.Message, ex); } } Page.Session["PublishedApps"] = apps; } Logger.Default.Info(LogLocation, string.Format("LoadWebPartView: End creating icons {0}", watch.Elapsed)); }