Example #1
0
        private void ctlOpenDirectory_Click(object sender, EventArgs e)
        {
            if (this.ctlList.SelectedItems.Count == 1)
            {
                Process.Start(new ProcessStartInfo("explorer", string.Format("/select,\"{0}\"", ((KisboFile)this.ctlList.SelectedItems[0].Tag).FilePath))).Dispose();
            }
            else if (this.ctlList.SelectedItems.Count > 1)
            {
                var dic = new Dictionary <string, List <string> >(StringComparer.OrdinalIgnoreCase);

                KisboFile file;
                string    dir;
                for (int i = 0; i < this.ctlList.SelectedItems.Count; ++i)
                {
                    file = (KisboFile)this.ctlList.SelectedItems[i].Tag;
                    dir  = Path.GetDirectoryName(file.FilePath);

                    if (!dic.ContainsKey(dir))
                    {
                        dic.Add(dir, new List <string>());
                    }

                    dic[dir].Add(file.FilePath);
                }

                foreach (var st in dic)
                {
                    ExplorerHelper.OpenFolderAndSelectFiles(st.Key, st.Value.ToArray());
                }
            }
        }
Example #2
0
        internal override void UpdateDocument()
        {
            base.UpdateDocument();

            PdfDocument document = this.explorer.MainForm.Process.Document;

            if (document == null)
            {
                return;
            }

            this.tbxTitel.Text    = document.Info.Title;
            this.tbxAuthor.Text   = document.Info.Author;
            this.tbxSubject.Text  = document.Info.Subject;
            this.tbxKeywords.Text = document.Info.Keywords;

            this.txtCreated.Text = document.Info.CreationDate.ToShortDateString() + " " +
                                   document.Info.CreationDate.ToLongTimeString();
            this.txtModified.Text = document.Info.ModificationDate.ToShortDateString() + " " +
                                    document.Info.ModificationDate.ToLongTimeString();
            this.txtApplication.Text = document.Info.Creator;
            this.txtProcuder.Text    = document.Info.Producer;
            this.txtVersion.Text     =
                String.Format("{0}.{1} (Acrobat {2}.x)", document.Version / 10, document.Version % 10, document.Version % 10 + 1);
            this.txtFileSize.Text =
                String.Format("{0:0,000} Byte", document.FileSize.ToString());
            int pageCount = document.PageCount;

            if (pageCount > 0)
            {
                this.txtPageSize.Text = ExplorerHelper.PageSize(document.Pages[0], this.explorer.Process.IsMetric);
            }
            this.txtPages.Text   = pageCount.ToString();
            this.txtObjects.Text = document.Internals.GetAllObjects().Length.ToString();
        }
Example #3
0
        /// <summary>
        /// Invoked when the effective property value of the Source property changes.
        /// </summary>
        /// <param name="dependencyObject">The DependencyObject on which the property has changed value.</param>
        /// <param name="dependencyPropertyChangedEventArgs">Event data that is issued by any event that tracks changes to the effective value of this property.
        /// </param>
        private static void OnSourcePropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
        {
            // This will disable the navigation when the source URI is changed retroactively to the page navigation.  That is, when the journal, forward button,
            // backward button change the current page, the source URI is set after the fact in order to reflect the location of the selected page.  Conversly,
            // when a breadcrumb control or tree view changes the source URI, that should be taken as an instruction to navigate to the selected page.
            ViewPage viewPage  = dependencyObject as ViewPage;
            Uri      newSource = dependencyPropertyChangedEventArgs.NewValue as Uri;

            // When the source URI has changed we need a new data context for the new source URI.  This effectively chooses the items that appear in any one of the
            // views provided by this class by selecting the IExplorerItem as the data context for the page.
            if (newSource != null)
            {
                IExplorerItem rootItem      = viewPage.DataContext as IExplorerItem;
                IExplorerItem iExplorerItem = ExplorerHelper.FindExplorerItem(rootItem, newSource);
                if (iExplorerItem != null)
                {
                    IExplorerItem       parentItem         = iExplorerItem;
                    CompositeCollection compositCollection = new CompositeCollection();
                    compositCollection.Add(new CollectionContainer()
                    {
                        Collection = parentItem as IEnumerable
                    });
                    compositCollection.Add(new CollectionContainer()
                    {
                        Collection = parentItem.Leaves
                    });
                    viewPage.listBoxView.ItemsSource = compositCollection;
                }
            }
        }
Example #4
0
        /// <summary>
        /// If a balloon tip is show for a taken capture, this handles the click on it
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpenCaptureOnClick(object sender, EventArgs e)
        {
            SurfaceMessageEventArgs eventArgs = MainForm.Instance.NotifyIcon.Tag as SurfaceMessageEventArgs;

            if (eventArgs == null)
            {
                Log.Warn("OpenCaptureOnClick called without SurfaceMessageEventArgs");
                RemoveEventHandler(sender, e);
                return;
            }
            ISurface surface = eventArgs.Surface;

            if (surface != null)
            {
                switch (eventArgs.MessageType)
                {
                case SurfaceMessageTyp.FileSaved:
                    ExplorerHelper.OpenInExplorer(surface.LastSaveFullPath);
                    break;

                case SurfaceMessageTyp.UploadedUri:
                    Process.Start(surface.UploadUrl);
                    break;
                }
            }
            Log.DebugFormat("Deregistering the BalloonTipClicked");
            RemoveEventHandler(sender, e);
        }
Example #5
0
        /// <summary>
        /// Handles a change to the interpreted Source URI for this frame.
        /// </summary>
        /// <param name="oldUri">The old Source URI.</param>
        /// <param name="newUri">The new Source URI.</param>
        protected override void OnSourceChanged(Uri oldUri, Uri newUri)
        {
            // The main idea here is that we have a data model that streams in.  There is no 'start' or 'end' of load, so we need to deal with the model as it
            // builds itself. Because the AssetNetworkCollection can build itself incrementally as data loads, we can get into a scenario where the outline of the
            // list is built and all the resources are loaded, but we haven't yet loaded the 'Property Store' table, where the metadata containing the viewer for
            // any given object is kept.  This logic here will hook itself into the current AssetNetworkItem selected and watch for an update to the viewer.  If
            // and when a new viewer should arrive, we'll just poke it in.  This will unhook the previous AssetNetworkItem from watching for the change.
            if (oldUri != null)
            {
                AssetNetworkItem oldItem = ExplorerHelper.FindExplorerItem(this.DataContext as IExplorerItem, oldUri) as AssetNetworkItem;
                if (oldItem != null)
                {
                    oldItem.PropertyChanged -= this.OnItemPropertyChanged;
                }
            }

            // This will allow us to poke a new viewer in should the properties for the current AssetNetworkItem selected be changed by an update from the data
            // model.
            if (newUri != null)
            {
                AssetNetworkItem newItem = ExplorerHelper.FindExplorerItem(this.DataContext as IExplorerItem, newUri) as AssetNetworkItem;
                if (newItem != null)
                {
                    newItem.PropertyChanged += this.OnItemPropertyChanged;
                }
            }
        }
Example #6
0
        /// <summary>
        /// Invoked when an unhandled DragDrop.DragEnter attached event reaches an element in its route that is derived from this class.
        /// </summary>
        /// <param name="dragEventArgs">The DragEventArgs that contains the event data.</param>
        protected override void OnDrop(DragEventArgs dragEventArgs)
        {
            // Close (and dereference) the window used to display the object being dragged.
            this.dragWindow.Close();
            this.dragWindow = null;

            // Attempt to find the element currently selected in the page.  This item will be the parent of any object dropped onto the surface.
            CategoryCollection parentItem = ExplorerHelper.FindExplorerItem(this.DataContext as CategoryCollection, this.Source) as CategoryCollection;

            if (parentItem != null)
            {
                // We can import files dropped onto the surface.  If the format specifies one or more files dragged from the Windows Explorer, then set call a
                // handler to import each filed based on the file type (that is, the extension).
                String[] paths = dragEventArgs.Data.GetData("FileDrop") as String[];
                if (paths != null)
                {
                    foreach (String path in paths)
                    {
                        ItemProperty externalObject;
                        if (CategoryPage.itemProperties.TryGetValue(Path.GetExtension(path).ToLower(), out externalObject))
                        {
                            CategoryPage.CreateItem(parentItem, path, externalObject);
                        }
                    }
                }
            }
        }
Example #7
0
        private void Start()
        {
            int width  = _imgList[0].BitmapImage.Width;
            int height = _imgList[0].BitmapImage.Height;

            Console.WriteLine("--Sprites per Line: ");

            int spritesPerLine = int.Parse(Console.ReadLine());

            Color[][] newImageMatrix = ImageProcessing.CreateBlankColorMatrix((width + 2) * spritesPerLine, (height + 2) * (int)Math.Ceiling(_imgList.Count / (double)spritesPerLine));

            int accX  = 1;
            int accY  = 1;
            int index = 0;

            foreach (ImportedImage img in _imgList)
            {
                ImageProcessing.AddImageIntoMatrix(newImageMatrix, img.BitmapImage, accX, accY);

                accX += width + 2;

                if (++index % spritesPerLine == 0)
                {
                    accY += height + 2;
                    accX  = 1;
                }
            }

            ImageProcessing.CreateImage(newImageMatrix).Save(Parameters.SpritesheetOutputDirectory + @"output.png");
            ExplorerHelper.OpenDirectory(Parameters.SpritesheetOutputDirectory);
            Thread.Sleep(1500);
            PaintHelper.OpenPictureFromOutputFolder(Parameters.SpritesheetOutputDirectory + @"output.png");
        }
        /// <summary>
        /// Main Window of the License Generator application.
        /// </summary>
        public MainWindow()
        {
            // The IDE generated controls are initialized here.
            this.InitializeComponent();

            // The immutable command bindings are found here.
            this.CommandBindings.Add(new CommandBinding(LicenseCommand.GenerateLicense, this.OnGenerateLicense));

            this.GenerateSeedData();

            ObservableCollection <RootCollection> root = new ObservableCollection <RootCollection>();

            root.Add(new RootCollection());
            this.DataContext = root;

            Binding itemsSourceBinding = new Binding();

            itemsSourceBinding.Source = this.DataContext;
            BindingOperations.SetBinding(this, MainWindow.ItemsSourceProperty, itemsSourceBinding);

            // This will have the effect of setting the current path to the root of the given hierarchy.
            if (this.Items.Count != 0)
            {
                IExplorerItem iExplorerItem = this.Items[0] as IExplorerItem;
                if (iExplorerItem != null)
                {
                    this.Source = ExplorerHelper.GenerateSource(iExplorerItem);
                }
            }
        }
Example #9
0
        /// <summary>
        /// Initializes ManagedShell with a custom configuration.
        /// </summary>
        /// <param name="config">A ShellConfig struct containing desired initialization parameters.</param>
        public ShellManager(ShellConfig config)
        {
            if (config.EnableTrayService)
            {
                TrayService         = new TrayService();
                ExplorerTrayService = new ExplorerTrayService();
                NotificationArea    = new NotificationArea(config.PinnedNotifyIcons, TrayService, ExplorerTrayService);
            }

            if (config.EnableTasksService)
            {
                TasksService = new TasksService(config.TaskIconSize);
                Tasks        = new Tasks(TasksService);
            }

            FullScreenHelper = new FullScreenHelper();
            ExplorerHelper   = new ExplorerHelper(NotificationArea);
            AppBarManager    = new AppBarManager(ExplorerHelper);

            if (config.EnableTrayService && config.AutoStartTrayService)
            {
                NotificationArea.Initialize();
            }

            if (config.EnableTasksService && config.AutoStartTasksService)
            {
                Tasks.Initialize();
            }
        }
Example #10
0
    void OnExportEnd(string destFile)
    {
        exporting = false;

        ExplorerHelper.ShowPathInExplorer(destFile);

        done = true;
    }
 /// <summary>
 /// Handles the CollectionChanged event.
 /// </summary>
 /// <param name="sender">The Object that raised the event.</param>
 /// <param name="e">Information about the event.</param>
 void OnItemsCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
 {
     // If the collection used for navigation changes (i.e. if a user were to log in with another id), then we need to make sure that the Source is
     // synchronized to the new list.  This will basically select the first child of the hierarchy when the collection is changed.
     if (e.Action == NotifyCollectionChangedAction.Add && this.Items.Count != 0)
     {
         Uri newUri = ExplorerHelper.GenerateSource(this.Items[0] as ExplorerItem);
         if (this.Source != newUri)
         {
             this.Source = newUri;
         }
     }
 }
Example #12
0
        private void RevealInExplorer(FileContentSearchResult searchResult)
        {
            var filePath = searchResult.FullPath;

            if (!File.Exists(filePath))
            {
                MessageBox.Show($"File {filePath} does not exist");
                return;
            }

            if (Path.GetDirectoryName(filePath) is string directory && Path.GetFileName(filePath) is string fileName)
            {
                ExplorerHelper.OpenFolderAndSelectItem(directory, fileName);
            }
        }
Example #13
0
 /// <summary>
 /// Opens the given item.
 /// </summary>
 /// <param name="frameworkElement">The selected element to be opened.</param>
 void OpenItem(FrameworkElement frameworkElement)
 {
     // This will open a user interface element that has an IExplorerItem associated with it (as long as the element selectes is not the root element).
     if (frameworkElement != null && frameworkElement.DataContext != this.DataContext)
     {
         IExplorerItem iExplorerItem = frameworkElement.DataContext as IExplorerItem;
         if (iExplorerItem != null)
         {
             Uri source = ExplorerHelper.GenerateSource(iExplorerItem);
             if (this.Source != source)
             {
                 this.Source = source;
             }
         }
     }
 }
Example #14
0
        private void Start()
        {
            (int, int)maxImageSize  = (imgList.Max((x) => x.BitmapImage.Width), imgList.Max((x) => x.BitmapImage.Height));
            (int, int)maxImagePivot = (imgList.Max((x) => x.Pivot.Item1), imgList.Max((x) => x.Pivot.Item2));
            (int, int)minImagePivot = (imgList.Min((x) => x.Pivot.Item1), imgList.Min((x) => x.Pivot.Item2));

            (int, int)newSize = (
                maxImageSize.Item1 + Math.Max(Math.Abs(minImagePivot.Item1), Math.Abs(minImagePivot.Item1)),
                maxImageSize.Item2 + Math.Max(Math.Abs(maxImagePivot.Item2), Math.Abs(minImagePivot.Item2)));

            Console.WriteLine("Sprites per line: ");
            int imgPerLine = int.Parse(Console.ReadLine());

            Console.WriteLine("Squish X factor:");
            int squishXFactor = int.Parse(Console.ReadLine());

            Console.WriteLine("Squish Y factor:");
            int squishYFactor = int.Parse(Console.ReadLine());

            Console.WriteLine("Offset X factor:");
            int offsetX = int.Parse(Console.ReadLine());

            Console.WriteLine("Offset Y factor:");
            int offsetY = int.Parse(Console.ReadLine());

            (int, int)newBigImageSize = ((newSize.Item1 - squishXFactor) * imgPerLine, (newSize.Item2 - squishYFactor) * (int)Math.Ceiling((double)imgList.Count() / imgPerLine));

            Color[][] nCM = ImageProcessing.CreateBlankColorMatrix(newBigImageSize.Item1, newBigImageSize.Item2);

            int index = 0;
            int w     = 0;
            int h     = 0;

            foreach (ImportedImage img in imgList)
            {
                w = offsetX + (newSize.Item1 - squishXFactor) * (index % imgPerLine) + newSize.Item1 / 2 + img.Pivot.Item1;
                h = offsetY + (newSize.Item2 - squishYFactor) * (index / imgPerLine) + newSize.Item2 / 2 + img.Pivot.Item2;
                ImageProcessing.AddImageIntoMatrix(nCM, img.BitmapImage, w, h);
                index++;
            }

            ImageProcessing.CreateImage(nCM).Save(Parameters.SpritesheetOutputDirectory + @"output.png");
            ExplorerHelper.OpenDirectory(Parameters.SpritesheetOutputDirectory);
            Thread.Sleep(1500);
            PaintHelper.OpenPictureFromOutputFolder(Parameters.SpritesheetOutputDirectory + @"output.png");
        }
Example #15
0
 /// <summary>
 /// Navigate to the given source URI.
 /// </summary>
 /// <param name="source">A fully qualified description of an item in the hierarchy.</param>
 void NavigateTo(Uri source)
 {
     // When we have a valid data context and a source, this will find the item in the hiearchy given the source and select it, optionally opening up its
     // parent if one exists.
     if (this.DataContext != null && source != null)
     {
         IExplorerItem iExplorerItem = ExplorerHelper.FindExplorerItem(this.DataContext as IExplorerItem, source);
         if (iExplorerItem != null)
         {
             IExplorerItem parent = iExplorerItem.Parent;
             if (parent != null)
             {
                 parent.IsExpanded = true;
             }
             iExplorerItem.IsSelected = true;
         }
     }
 }
Example #16
0
        /// <summary>
        ///     The Contextmenu_OpenRecent currently opens the last know save location
        /// </summary>
        private void Contextmenu_OpenRecent(object sender, EventArgs eventArgs)
        {
            _coreConfiguration.ValidateAndCorrectOutputFilePath();
            _coreConfiguration.ValidateAndCorrectOutputFileAsFullpath();
            var path = _coreConfiguration.OutputFileAsFullpath;

            if (!File.Exists(path))
            {
                path = FilenameHelper.FillVariables(_coreConfiguration.OutputFilePath, false);
                // Fix for #1470, problems with a drive which is no longer available
                try
                {
                    var lastFilePath = Path.GetDirectoryName(_coreConfiguration.OutputFileAsFullpath);

                    if (lastFilePath != null && Directory.Exists(lastFilePath))
                    {
                        path = lastFilePath;
                    }
                    else if (!Directory.Exists(path))
                    {
                        // What do I open when nothing can be found? Right, nothing...
                        return;
                    }
                }
                catch (Exception ex)
                {
                    Log.Warn().WriteLine(ex, "Couldn't open the path to the last exported file, taking default.");
                }
            }
            try
            {
                ExplorerHelper.OpenInExplorer(path);
            }
            catch (Exception ex)
            {
                // Make sure we show what we tried to open in the exception
                ex.Data.Add("path", path);
                Log.Warn().WriteLine(ex, "Couldn't open the path to the last exported file");
                // No reason to create a bug-form, we just display the error.
                MessageBox.Show(this, ex.Message, $"Opening {path}", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void dropTimer_Tick(object sender, EventArgs e)
        {
            bool mouseButtonsReleased = false;

            if (MouseButtonPressed == MouseButtons.Left && !IsKeyPressed(VirtualKeyStates.VK_LBUTTON))
            {
                mouseButtonsReleased = true;
            }
            else if (MouseButtonPressed == MouseButtons.Right && !IsKeyPressed(VirtualKeyStates.VK_RBUTTON))
            {
                mouseButtonsReleased = true;
            }
            if (mouseButtonsReleased)
            {
                dropTimer.Enabled = false;
                int    handle   = ExplorerHelper.GetActiveWindowHandle();
                string dropPath = GetWindowsExplorerPathFromWindowHandle(handle);
                MessageBox.Show(dropPath);     // Here is where the Windows Explorer path is shown
            }
        }
Example #18
0
        void FillStreamBox()
        {
            PdfItem       item = this.explorer.MainForm.Process.Navigator.Current;
            PdfDictionary dict = item as PdfDictionary;

            if (dict.Stream == null)
            {
                this.pnlBottom.Enabled = false;
                this.tbxStream.Text    = "";
                return;
            }

            this.pnlBottom.Enabled = true;

            if (dict != null && dict.Stream != null && dict.Stream.Value != null)
            {
                byte[] stream = this.btnNoFilter.Checked ? dict.Stream.UnfilteredValue : dict.Stream.Value;
                if (btnHexdump.Checked)
                {
                    this.tbxStream.Text = ExplorerHelper.HexDump(stream);
                }
                else
                {
                    int    count = stream.Length;
                    char[] chars = new char[count];
                    for (int idx = 0; idx < count; idx++)
                    {
                        byte b = stream[idx];
                        if (b == 0)
                        {
                            b = 183;
                        }
                        chars[idx] = (char)b;
                    }
                    this.tbxStream.Text = new string(chars);
                }
            }
        }
Example #19
0
        /// <summary>
        /// Invoked when the effective property value of the Source property changes.
        /// </summary>
        /// <param name="dependencyObject">The DependencyObject on which the property has changed value.</param>
        /// <param name="dependencyPropertyChangedEventArgs">Event data that is issued by any event that tracks changes to the effective value of this property.
        /// </param>
        private static void OnSourcePropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
        {
            // This will disable the navigation when the source URI is changed retroactively to the page navigation.  That is, when the journal, forward button,
            // backward button change the current page, the source URI is set after the fact in order to reflect the location of the selected page.  Conversly,
            // when a breadcrumb control or tree view changes the source URI, that should be taken as an instruction to navigate to the selected page.
            PdfPage pdfPage   = dependencyObject as PdfPage;
            Uri     newSource = dependencyPropertyChangedEventArgs.NewValue as Uri;

            // When the source URI has changed we need a new data context for the new source URI.  This effectively chooses the items that appear in any one of the
            // views provided by this class by selecting the IExplorerItem as the data context for the page.
            if (newSource != null)
            {
                IExplorerItem rootItem      = pdfPage.DataContext as IExplorerItem;
                IExplorerItem iExplorerItem = ExplorerHelper.FindExplorerItem(rootItem, newSource);
                if (iExplorerItem != null && iExplorerItem.Data != null)
                {
                    MemoryStream memoryStream = new MemoryStream(iExplorerItem.Data);
                    memoryStream.Position = 0L;
                    pdfPage.pdfPageView.PageDisplayLayout = PDFPageDisplayLayout.OneColumn;
                    pdfPage.pdfPageView.Document.Load(memoryStream);
                }
            }
        }
Example #20
0
        public void Start()
        {
            List <ImportedImage> imgListSFX = _imgListSFX.ToList();
            List <ImportedImage> imgList    = _imgList.ToList();

            int[] imagePerLayer = new int[] { imgList.Count, imgListSFX.Count };

            imgList.AddRange(imgListSFX);

            (int, int)maxImageSize  = (imgList.Max((x) => x.BitmapImage.Width), imgList.Max((x) => x.BitmapImage.Height));
            (int, int)maxImagePivot = (imgList.Max((x) => x.Pivot.Item1), imgList.Max((x) => x.Pivot.Item2));
            (int, int)minImagePivot = (imgList.Min((x) => x.Pivot.Item1), imgList.Min((x) => x.Pivot.Item2));

            (int, int)newSize = (
                maxImageSize.Item1 + Math.Max(Math.Abs(minImagePivot.Item1), Math.Abs(minImagePivot.Item1)),
                maxImageSize.Item2 + Math.Max(Math.Abs(maxImagePivot.Item2), Math.Abs(minImagePivot.Item2)));

            Console.WriteLine("Sprites per line: ");
            int imgPerLine = int.Parse(Console.ReadLine());

            Console.WriteLine("Squish X factor:");
            int squishXFactor = int.Parse(Console.ReadLine());

            Console.WriteLine("Squish Y factor:");
            int squishYFactor = int.Parse(Console.ReadLine());

            Console.WriteLine("Initial X Shift factor:");
            int initialXFactor = int.Parse(Console.ReadLine());

            Console.WriteLine("Initial Y Shift factor:");
            int initialYFactor = int.Parse(Console.ReadLine());

            (int, int)newBigImageSize = ((newSize.Item1 - squishXFactor + initialXFactor) * imgPerLine, (newSize.Item2 - squishYFactor) * (int)Math.Ceiling((double)imagePerLayer[0] / imgPerLine));

            Color[][] nCM1 = ImageProcessing.CreateBlankColorMatrix(newBigImageSize.Item1, newBigImageSize.Item2);
            Color[][] nCM2 = ImageProcessing.CreateBlankColorMatrix(newBigImageSize.Item1, newBigImageSize.Item2);

            int index = 0;
            int w     = 0;
            int h     = 0;

            bool reaply = false;

            foreach (ImportedImage img in imgList)
            {
                w = initialXFactor + /* * (1 + (index % imgPerLine))*/ +(newSize.Item1 - squishXFactor) * (index % imgPerLine) + newSize.Item1 / 2 + img.Pivot.Item1;
                h = initialYFactor + (newSize.Item2 - squishYFactor) * (index / imgPerLine) + newSize.Item2 / 2 + img.Pivot.Item2;

                if (!reaply)
                {
                    ImageProcessing.AddImageIntoMatrix(nCM1, img.BitmapImage, w, h);
                    ImageProcessing.AddImageIntoMatrix(nCM2, img.BitmapImage, w, h);
                }
                else
                {
                    ImageProcessing.BlendImageIntoMatrix(nCM1, img.BitmapImage, w, h, (y, x) =>
                    {
                        return(ColorBlending.MultiChannelAlphaBlending(x, y));
                    });

                    ImageProcessing.BlendImageIntoMatrix(nCM2, img.BitmapImage, w, h, (x, y) =>
                    {
                        return(ColorBlending.MultiChannelAlphaBlending(x, y));
                    });
                }

                if (++index == imagePerLayer[0] && !reaply)
                {
                    reaply = true;
                    index  = 0;
                }
            }

            ImageProcessing.BlendImageIntoMatrix(nCM1, ImageProcessing.CreateImage(nCM2), 0, 0, (x, y) =>
            {
                return(Color.FromArgb(Math.Max(x.A, y.A), Math.Max(x.R, y.R), Math.Max(x.G, y.G), Math.Max(x.B, y.B)));
            });

            ImageProcessing.CreateImage(nCM1).Save(Parameters.SpritesheetOutputDirectory + @"output.png");

            ExplorerHelper.OpenDirectory(Parameters.SpritesheetOutputDirectory);
            Thread.Sleep(1500);
            PaintHelper.OpenPictureFromOutputFolder(Parameters.SpritesheetOutputDirectory + @"output.png");
        }
Example #21
0
        public static void Main(string[] args)
        {
            AllocConsole();


            //Preventing exceptions when outputing assets
            ExplorerHelper.CreateAllFolders();

            do
            {
                Console.WriteLine("Gunbound Raw Image Fix Tools");

                Console.WriteLine("SpriteSheet tools");
                Console.WriteLine("A1 - Create Spritesheet [SFX][Custom Image Size][1-Layer]");
                Console.WriteLine("A2 - Create Spritesheet [SFX][Custom Image Size][2-Layer - AlphaBlend]");
                Console.WriteLine("A3 - Create Spritesheet [Equal Images]");

                Console.WriteLine("\nImage Utils");
                Console.WriteLine("B1 - Image Border Fixer");

                Console.WriteLine("\nImage Processing");
                Console.WriteLine("C1 - Massive .IMG import.");
                Console.WriteLine("C2 - IMG Crack [Mobiles]");
                Console.WriteLine("C3 - Image Sync Comparer [DEPRECATED]");
                Console.WriteLine("C4 - Image Comparer");

                Console.WriteLine("\nFile manipulation");
                Console.WriteLine("D1 - Name Fixer.");
                Console.WriteLine("D2 - Pivot Offset Fixer");

                Console.WriteLine("\nDecrypt/Cypher");
                Console.WriteLine("E1 - XTF Crack");

                Console.WriteLine("\nCreate Assets");
                Console.WriteLine("F1 - Crosshair Drawer");
                Console.WriteLine("F2 - Mobile Buttons");
                Console.WriteLine("F3 - Create Minimap Tumbnails");
                Console.WriteLine("F4 - Spritefont Range Builder");
                Console.WriteLine("F5 - Item buttons thumbnails");

                try
                {
                    DateTime sDate = DateTime.Now;

                    switch (Console.ReadLine().ToUpper())
                    {
                    case "A1":
                        new SingleLayerSpritesheetMaker().CreateSpritesheet();
                        break;

                    case "A2":
                        new MultiLayerSpritesheetMaker().CreateSpritesheet();
                        break;

                    case "A3":
                        new SimpleSpritesheetMaker().CreateSpritesheet();
                        break;

                    case "B1":
                        ImageBorderFix.FixBorder();
                        break;

                    case "C1":
                        new SpriteImportManager().ImportSprites();
                        break;

                    case "C2":
                        IMGCracker.ExportIMGData();
                        break;

                    case "C3":
                        ImageSyncComparer.ImageSyncCompare();
                        break;

                    case "C4":
                        ImageComparer.CompareImages();
                        break;

                    case "D1":
                        new FileNameFixer().ImportSprites();
                        break;

                    case "D2":
                        PivotFileManager.FixPivotFile();
                        break;

                    case "E1":
                        XTFCracker.Crack();
                        break;

                    case "F1":
                        CrosshairDrawer.DrawCrosshairs();
                        break;

                    case "F2":
                        new AssetMaker().CreateButton();
                        break;

                    case "F3":
                        MinimapThumbGenerator.GenerateButtonThumbnails();
                        break;

                    case "F4":
                        SpritefontRangeBuilder.BuildSpritefontRange();
                        break;

                    case "F5":
                        new AssetMaker().CreateItemButton();
                        break;

                    default:
                        throw new Exception();
                    }

                    Console.WriteLine("Process complete. Running time: " + (DateTime.Now - sDate).TotalSeconds);
                    Console.ReadKey();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.ReadKey();
                    Console.Clear();
                }
            } while (true);
        }
Example #22
0
    void CreateScreenshotSteps()
    {
        Debug.Log("START Taking ScreenShots");

        _screenshotSteps = new List <Action>();

        var    dateTimeString = _pauseTime.ToString("yyyy-MM-dd hh-mm-ss");
        string folderPath     = Application.persistentDataPath + "/Screenshots/" + dateTimeString + "/";

        if (!Directory.Exists(folderPath))
        {
            Directory.CreateDirectory(folderPath);
        }

        if (!_hasShownExplorer)
        {
            _hasShownExplorer = true;
            ExplorerHelper.ShowInExplorer(folderPath);
        }


        var originalSize = new Rect(0, 0, Screen.width, Screen.height);

        //var sizes = new List<Rect>();

        //sizes.Add(new Rect(0, 0, 800, 600));
        //sizes.Add(new Rect(0, 0, 150, 100));
        //sizes.Add(new Rect(0, 0, 100, 150));

        var sizes = ScreenshotSizeHelper.ScreenShotSizes.ToList();

        sizes.Insert(0, new Rect(0, 0, Screen.width, Screen.height));

        foreach (var s in sizes)
        {
            var size  = s;
            var index = _pauseScreenshotCount;

            // Skip impossible sizes
            var resolution = Screen.currentResolution;
            if (size.width > resolution.width ||
                size.height > resolution.height)
            {
                Debug.Log("Resolution not big enough for size: " + size.width + "x" + size.height);
                continue;
            }

            _screenshotSteps.Add(() =>
            {
                // Take Screenshot
                Screen.SetResolution((int)size.width, (int)size.height, false);
            });

            _screenshotSteps.Add(() =>
            {
                if (Screen.width == (int)size.width &&
                    Screen.height == (int)size.height)
                {
                    Application.CaptureScreenshot(
                        folderPath
                        + index
                        + " - " + (int)size.width + "x" + (int)size.height + ".png", 1);
                }
                else
                {
                    if (Application.isEditor)
                    {
                        Debug.Log("Cannot change resolution in editor preview. Run as standalone to create screenshots.");
                    }
                    else
                    {
                        Debug.Log("Failed to change resolution to " + " - " + (int)size.width + "x" + (int)size.height);
                    }
                }
            });

            _pauseScreenshotCount++;
        }

        _screenshotSteps.Add(() =>
        {
            Screen.SetResolution((int)originalSize.width, (int)originalSize.height, false);
        });

        _screenshotSteps.Add(() =>
        {
            _isTakingScreenshots = false;

            Debug.Log("END Taking ScreenShots");
        });
    }